@Override
  public void doFilter(String channel, String message, FilterChain chain) {
    // 收集当前节点中所有的logger和级别,汇报给clip_admin
    if (channel.equals(Coordinator.channel_collect_pull_logger)) {
      /*
       * 处理log4j设置上报
       */
      Enumeration<?> loggers = LogManager.getCurrentLoggers();
      if (loggers != null) {
        List<KV> list = new ArrayList<KV>();
        while (loggers.hasMoreElements()) {
          Logger logger = (Logger) loggers.nextElement();
          String name = logger.getName();
          Level level = logger.getLevel();
          if (level == null) continue;

          String levelStr = level.toString();
          KV kv = new KV();
          kv.setK(name);
          kv.setV(levelStr);
          kv.setAttach(Context.getInstance().getAttribute(Context.attach));
          list.add(kv);

          log.info(name + " --- " + levelStr);
        }

        /*
         * 收集root logger级别
         */
        Logger rootLogger = LogManager.getRootLogger();
        KV kv = new KV();
        kv.setK(rootLogger.getName());
        kv.setV(rootLogger.getLevel().toString());
        kv.setAttach(Context.getInstance().getAttribute(Context.attach));
        list.add(kv);
        log.info(kv.getK() + " --- " + kv.getV());

        Report report = new Report();
        report.setNode((Node) Context.getInstance().getAttribute(Context.node));
        report.setList(list);

        JedisFace jedis =
            ((PooledJedis) Context.getInstance().getAttribute(Context.poolJedis)).getJedisProxy();
        Long client =
            jedis.publish(Coordinator.channel_collect_push_logger, JsonUtil.java2json(report));
        log.info(client + " 个客户端接收到日志收集信息");
      }
      return;
    } else {
      chain.doFilter(channel, message);
    }
  }
  protected void initServerSocket() {
    try {
      // this.addConnectionObserver(connObserver);
      // create a listening socket and add it to the select set
      ssocket = ServerSocketChannel.open();
      ssocket.configureBlocking(false);

      InetSocketAddress isa = null;
      if (ipAddress != null) {
        isa = new InetSocketAddress(ipAddress, port);
      } else {
        isa = new InetSocketAddress(port);
      }

      ssocket.socket().bind(isa, this.backlog);
      registerServerChannel(ssocket);

      Level level = log.getLevel();
      log.setLevel(Level.INFO);
      log.info(this.getName() + " listening on " + isa + ".");
      log.setLevel(level);

    } catch (IOException ioe) {
      log.error("Failure listening to socket on port '" + port + "'.", ioe);
      System.err.println("Failure listening to socket on port '" + port + "'.");
      ioe.printStackTrace();
      System.exit(-1);
    }
  }
Beispiel #3
0
  @BeforeClass
  public static void configure() throws Exception {
    Tools.configure();

    logger.setLevel(Level.TRACE);
    Tools.setLevel(
        new String[] {StarterNode.class.toString(), Starter.class.toString()}, logger.getLevel());
  }
Beispiel #4
0
 /**
  * 开始Trace. 降低项目默认Logger的级别到DEBUG, 同时打开traceAppender的阀值到Debug. 需要先注入项目默认Logger名称及traceAppender名称.
  */
 @ManagedOperation(description = "Start trace")
 public void startTrace() {
   AssertUtils.hasText(traceAppenderName);
   Logger logger = Logger.getLogger(projectLoggerName);
   projectLoggerOrgLevel = logger.getLevel();
   logger.setLevel(Level.DEBUG);
   setTraceAppenderThreshold(logger, Level.DEBUG);
   mbeanLogger.info("Start trace");
 }
Beispiel #5
0
 private void outputNodeInfo() {
   if (!logger.getLevel().equals(Level.DEBUG)) {
     return;
   }
   System.out.println("---- Query: [" + query + "]");
   for (int i = 0; i < elements.size(); i++) {
     System.out.println("--->   Node[" + i + "]: " + elements.get(i));
   }
 }
Beispiel #6
0
 /**
  * log_level
  *
  * <p>Return the current logging level as defined by the Logging Interface IDL
  *
  * @return int value of a CF::LogLevels enumeration
  */
 public int log_level() {
   if (_logger != null) {
     Level logger_level = _logger.getLevel();
     Level cur_loglevel = logging.ConvertToLog4Level(logLevel);
     if (logger_level != null && logger_level != cur_loglevel) {
       logLevel = logging.ConvertLog4ToCFLevel(logger_level);
     }
   }
   return logLevel;
 }
 public void shutdown() {
   Level level = log.getLevel();
   log.setLevel(Level.INFO);
   super.shutdown();
   try {
     ssocket.close();
   } catch (IOException e) {
   }
   log.warn(this.getName() + " shutdown completed!");
   log.setLevel(level);
 }
  @Managed(description = "Get the log level for the specified logger")
  public String getLevel(final String loggerName) {
    final Logger logger;

    if (!StringUtils.isEmpty(loggerName)) {
      logger = LogManager.getLogger(loggerName);
    } else {
      logger = LogManager.getRootLogger();
    }

    return logger.getLevel().toString();
  }
  /** test internally--is data structure consistent for first go manual. */
  public void testForwardNextStep_SingleGoManualInternally() {
    Logger logger = Logger.getLogger(GoBoard.class);
    if (logger.getLevel().isGreaterOrEqual(Level.INFO)) {

    } else {
      logger.setLevel(Level.INFO);
    }
    byte[] original = null;
    SimpleGoManual riginal = new LoadGMDGoManual(rootDir).loadSingleGoManual();
    // helperTestMethod(original);
    helperTestMethod_CountTime(riginal);
    log.debug("success of testForwardNextStepSingleGoManualInternally");
  }
  /** This method must work for the root category as well. */
  void parseCategory(
      Properties props, Logger logger, String optionKey, String loggerName, String value) {

    LogLog.debug("Parsing for [" + loggerName + "] with value=[" + value + "].");
    // We must skip over ',' but not white space
    StringTokenizer st = new StringTokenizer(value, ",");

    // If value is not in the form ", appender.." or "", then we should set
    // the level of the loggeregory.

    if (!(value.startsWith(",") || value.equals(""))) {

      // just to be on the safe side...
      if (!st.hasMoreTokens()) return;

      String levelStr = st.nextToken();
      LogLog.debug("Level token is [" + levelStr + "].");

      // If the level value is inherited, set category level value to
      // null. We also check that the user has not specified inherited for the
      // root category.
      if (INHERITED.equalsIgnoreCase(levelStr) || NULL.equalsIgnoreCase(levelStr)) {
        if (loggerName.equals(INTERNAL_ROOT_NAME)) {
          LogLog.warn("The root logger cannot be set to null.");
        } else {
          logger.setLevel(null);
        }
      } else {
        logger.setLevel(OptionConverter.toLevel(levelStr, (Level) Level.DEBUG));
      }
      LogLog.debug("Category " + loggerName + " set to " + logger.getLevel());
    }

    // Begin by removing all existing appenders.
    logger.removeAllAppenders();

    Appender appender;
    String appenderName;
    while (st.hasMoreTokens()) {
      appenderName = st.nextToken().trim();
      if (appenderName == null || appenderName.equals(",")) continue;
      LogLog.debug("Parsing appender named \"" + appenderName + "\".");
      appender = parseAppender(props, appenderName);
      if (appender != null) {
        logger.addAppender(appender);
      }
    }
  }
Beispiel #11
0
  public void testLogging() {
    s_logger.info("Testing Logging");
    GetHostStatsCommand cmd3 = new GetHostStatsCommand("hostguid", "hostname", 101);
    Request sreq = new Request(2, 3, new Command[] {cmd3}, true, true);
    sreq.setSequence(1);
    Logger logger = Logger.getLogger(GsonHelper.class);
    Level level = logger.getLevel();

    logger.setLevel(Level.DEBUG);
    String log = sreq.log("Debug", true, Level.DEBUG);
    assert (log == null);

    log = sreq.log("Debug", false, Level.DEBUG);
    assert (log != null);

    logger.setLevel(Level.TRACE);
    log = sreq.log("Trace", true, Level.TRACE);
    assert (log.contains(GetHostStatsCommand.class.getSimpleName()));
    s_logger.debug(log);

    logger.setLevel(level);
  }
Beispiel #12
0
 @BeforeClass
 public static void init() {
   Logger.getRootLogger().setLevel(Level.DEBUG);
   logger.info("Starting MAGE tests");
   logger.info("Logging level: " + logger.getLevel());
   deleteSavedGames();
   ConfigSettings config = ConfigSettings.getInstance();
   for (GamePlugin plugin : config.getGameTypes()) {
     GameFactory.getInstance()
         .addGameType(plugin.getName(), loadGameType(plugin), loadPlugin(plugin));
   }
   for (GamePlugin plugin : config.getTournamentTypes()) {
     TournamentFactory.getInstance()
         .addTournamentType(plugin.getName(), loadTournamentType(plugin), loadPlugin(plugin));
   }
   for (Plugin plugin : config.getPlayerTypes()) {
     PlayerFactory.getInstance().addPlayerType(plugin.getName(), loadPlugin(plugin));
   }
   //        for (Plugin plugin : config.getDeckTypes()) {
   //            DeckValidatorFactory.getInstance().addDeckType(plugin.getName(),
   // loadPlugin(plugin));
   //        }
   Copier.setLoader(classLoader);
 }
 public static void setLogLevel(Level level) {
   if (LOGGER_LEVEL.compareAndSet(null, ROOT_LOGGER.getLevel())) {
     ROOT_LOGGER.setLevel(level);
   }
 }
 public Log4jLogger(Logger logger) {
   this.logger = logger;
   org.apache.log4j.Level log4jLevel = logger.getLevel();
   this.level = toStandardLevel(log4jLevel);
 }
  /*
   * Performs affine adaptation
   */
  boolean calcAffineAdaptation(
      final FImage fimage, EllipticInterestPointData kpt, AbstractStructureTensorIPD ipd) {
    //		DisplayUtilities.createNamedWindow("warp", "Warped Image ROI",true);
    Matrix transf = new Matrix(2, 3); // Transformation matrix
    Point2dImpl c = new Point2dImpl(); // Transformed point
    Point2dImpl p = new Point2dImpl(); // Image point

    Matrix U = Matrix.identity(2, 2); // Normalization matrix

    Matrix Mk = U.copy();
    FImage img_roi, warpedImg = new FImage(1, 1);
    float Qinv = 1, q, si = kpt.scale; // sd = 0.75f * si;
    float kptSize = 2 * 3 * kpt.scale;
    boolean divergence = false, convergence = false;
    int i = 0;

    // Coordinates in image
    int py = (int) kpt.y;
    int px = (int) kpt.x;

    // Roi coordinates
    int roix, roiy;

    // Coordinates in U-trasformation
    int cx = px;
    int cy = py;
    int cxPr = cx;
    int cyPr = cy;

    float radius = kptSize / 2 * 1.4f;
    float half_width, half_height;

    Rectangle roi;

    // Affine adaptation
    while (i <= 10 && !divergence && !convergence) {
      // Transformation matrix
      MatrixUtils.zero(transf);
      transf.setMatrix(0, 1, 0, 1, U);

      kpt.setTransform(U);

      Rectangle boundingBox = new Rectangle();

      double ac_b2 = U.det();
      boundingBox.width = (float) Math.ceil(U.get(1, 1) / ac_b2 * 3 * si * 1.4);
      boundingBox.height = (float) Math.ceil(U.get(0, 0) / ac_b2 * 3 * si * 1.4);

      // Create window around interest point
      half_width = Math.min((float) Math.min(fimage.width - px - 1, px), boundingBox.width);
      half_height = Math.min((float) Math.min(fimage.height - py - 1, py), boundingBox.height);

      if (half_width <= 0 || half_height <= 0) return divergence;

      roix = Math.max(px - (int) boundingBox.width, 0);
      roiy = Math.max(py - (int) boundingBox.height, 0);
      roi = new Rectangle(roix, roiy, px - roix + half_width + 1, py - roiy + half_height + 1);

      // create ROI
      img_roi = fimage.extractROI(roi);

      // Point within the ROI
      p.x = px - roix;
      p.y = py - roiy;

      // Find coordinates of square's angles to find size of warped ellipse's bounding box
      float u00 = (float) U.get(0, 0);
      float u01 = (float) U.get(0, 1);
      float u10 = (float) U.get(1, 0);
      float u11 = (float) U.get(1, 1);

      float minx = u01 * img_roi.height < 0 ? u01 * img_roi.height : 0;
      float miny = u10 * img_roi.width < 0 ? u10 * img_roi.width : 0;
      float maxx =
          (u00 * img_roi.width > u00 * img_roi.width + u01 * img_roi.height
                  ? u00 * img_roi.width
                  : u00 * img_roi.width + u01 * img_roi.height)
              - minx;
      float maxy =
          (u11 * img_roi.width > u10 * img_roi.width + u11 * img_roi.height
                  ? u11 * img_roi.height
                  : u10 * img_roi.width + u11 * img_roi.height)
              - miny;

      // Shift
      transf.set(0, 2, -minx);
      transf.set(1, 2, -miny);

      if (maxx >= 2 * radius + 1 && maxy >= 2 * radius + 1) {
        // Size of normalized window must be 2*radius
        // Transformation
        FImage warpedImgRoi;
        FProjectionProcessor proc = new FProjectionProcessor();
        proc.setMatrix(transf);
        img_roi.accumulateWith(proc);
        warpedImgRoi = proc.performProjection(0, (int) maxx, 0, (int) maxy, null);

        //				DisplayUtilities.displayName(warpedImgRoi.clone().normalise(), "warp");

        // Point in U-Normalized coordinates
        c = p.transform(U);
        cx = (int) (c.x - minx);
        cy = (int) (c.y - miny);

        if (warpedImgRoi.height > 2 * radius + 1 && warpedImgRoi.width > 2 * radius + 1) {
          // Cut around normalized patch
          roix = (int) Math.max(cx - Math.ceil(radius), 0.0);
          roiy = (int) Math.max(cy - Math.ceil(radius), 0.0);
          roi =
              new Rectangle(
                  roix,
                  roiy,
                  cx - roix + (float) Math.min(Math.ceil(radius), warpedImgRoi.width - cx - 1) + 1,
                  cy
                      - roiy
                      + (float) Math.min(Math.ceil(radius), warpedImgRoi.height - cy - 1)
                      + 1);
          warpedImg = warpedImgRoi.extractROI(roi);

          // Coordinates in cutted ROI
          cx = cx - roix;
          cy = cy - roiy;
        } else {
          warpedImg.internalAssign(warpedImgRoi);
        }

        if (logger.getLevel() == Level.DEBUG) {
          displayCurrentPatch(
              img_roi.clone().normalise(),
              p.x,
              p.y,
              warpedImg.clone().normalise(),
              cx,
              cy,
              U,
              si * 3);
        }

        // Integration Scale selection
        si = selIntegrationScale(warpedImg, si, new Pixel(cx, cy));

        // Differentation scale selection
        if (fastDifferentiationScale) {
          ipd = selDifferentiationScaleFast(warpedImg, ipd, si, new Pixel(cx, cy));
        } else {
          ipd = selDifferentiationScale(warpedImg, ipd, si, new Pixel(cx, cy));
        }

        if (ipd.maxima.size() == 0) {
          divergence = true;
          continue;
        }
        // Spatial Localization
        cxPr = cx; // Previous iteration point in normalized window
        cyPr = cy;
        //
        //				float cornMax = 0;
        //				for (int j = 0; j < 3; j++)
        //				{
        //					for (int t = 0; t < 3; t++)
        //					{
        //						float dx2 = Lxm2smooth.pixels[cyPr - 1 + j][cxPr - 1 + t];
        //						float dy2 = Lym2smooth.pixels[cyPr - 1 + j][cxPr - 1 + t];
        //						float dxy = Lxmysmooth.pixels[cyPr - 1 + j][cxPr - 1 + t];
        //						float det = dx2 * dy2 - dxy * dxy;
        //						float tr = dx2 + dy2;
        //						float cornerness = (float) (det - (0.04 * Math.pow(tr, 2)));
        //
        //						if (cornerness > cornMax) {
        //							cornMax = cornerness;
        //							cx = cxPr - 1 + t;
        //							cy = cyPr - 1 + j;
        //						}
        //					}
        //				}

        FValuePixel max = ipd.findMaximum(new Rectangle(cxPr - 1, cyPr - 1, 3, 3));
        cx = max.x;
        cy = max.y;

        // Transform point in image coordinates
        p.x = px;
        p.y = py;

        // Displacement vector
        c.x = cx - cxPr;
        c.y = cy - cyPr;

        // New interest point location in image
        p.translate(c.transform(U.inverse()));
        px = (int) p.x;
        py = (int) p.y;

        q = calcSecondMomentSqrt(ipd, new Pixel(cx, cy), Mk);

        float ratio = 1 - q;

        // if ratio == 1 means q == 0 and one axes equals to 0
        if (!Float.isNaN(ratio) && ratio != 1) {
          // Update U matrix
          U = U.times(Mk);

          Matrix uVal, uV;
          //					EigenvalueDecomposition ueig = U.eig();
          EigenValueVectorPair ueig = MatrixUtils.symmetricEig2x2(U);
          uVal = ueig.getValues();
          uV = ueig.getVectors();

          Qinv = normMaxEval(U, uVal, uV);

          // Keypoint doesn't converge
          if (Qinv >= 6) {
            logger.debug("QInverse too large, feature too edge like, affine divergence!");
            divergence = true;
          } else if (ratio <= 0.05) { // Keypoint converges
            convergence = true;

            // Set transformation matrix
            MatrixUtils.zero(transf);
            transf.setMatrix(0, 1, 0, 1, U);
            // The order here matters, setTransform uses the x and y to calculate a new ellipse
            kpt.x = px;
            kpt.y = py;
            kpt.scale = si;
            kpt.setTransform(U);
            kpt.score = max.value;

            //						ax1 = (float) (1 / Math.abs(uVal.get(1, 1)) * 3 * si);
            //						ax2 = (float) (1 / Math.abs(uVal.get(0, 0)) * 3 * si);
            //						phi = Math.atan(uV.get(1, 1) / uV.get(0, 1));
            //						kpt.axes = new Point2dImpl(ax1, ax2);
            //						kpt.phi = phi;
            //						kpt.centre = new Pixel(px, py);
            //						kpt.si = si;
            //						kpt.size = 2 * 3 * si;

          } else {
            radius = (float) (3 * si * 1.4);
          }
        } else {
          logger.debug("QRatio was close to 0, affine divergence!");
          divergence = true;
        }
      } else {
        logger.debug("Window size has grown too fast, scale divergence!");
        divergence = true;
      }

      ++i;
    }
    if (!divergence && !convergence) {
      logger.debug("Reached max iterations!");
    }
    return convergence;
  }
Beispiel #16
0
  public void testSerDeser() {
    s_logger.info("Testing serializing and deserializing works as expected");

    s_logger.info(
        "UpdateHostPasswordCommand should have two parameters that doesn't show in logging");
    UpdateHostPasswordCommand cmd1 = new UpdateHostPasswordCommand("abc", "def");
    s_logger.info(
        "SecStorageFirewallCfgCommand has a context map that shouldn't show up in debug level");
    SecStorageFirewallCfgCommand cmd2 = new SecStorageFirewallCfgCommand();
    s_logger.info("GetHostStatsCommand should not show up at all in debug level");
    GetHostStatsCommand cmd3 = new GetHostStatsCommand("hostguid", "hostname", 101);
    cmd2.addPortConfig("abc", "24", true, "eth0");
    cmd2.addPortConfig("127.0.0.1", "44", false, "eth1");
    Request sreq = new Request(2, 3, new Command[] {cmd1, cmd2, cmd3}, true, true);
    sreq.setSequence(892403717);

    Logger logger = Logger.getLogger(GsonHelper.class);
    Level level = logger.getLevel();

    logger.setLevel(Level.DEBUG);
    String log = sreq.log("Debug", true, Level.DEBUG);
    assert (log.contains(UpdateHostPasswordCommand.class.getSimpleName()));
    assert (log.contains(SecStorageFirewallCfgCommand.class.getSimpleName()));
    assert (!log.contains(GetHostStatsCommand.class.getSimpleName()));
    assert (!log.contains("username"));
    assert (!log.contains("password"));

    logger.setLevel(Level.TRACE);
    log = sreq.log("Trace", true, Level.TRACE);
    assert (log.contains(UpdateHostPasswordCommand.class.getSimpleName()));
    assert (log.contains(SecStorageFirewallCfgCommand.class.getSimpleName()));
    assert (log.contains(GetHostStatsCommand.class.getSimpleName()));
    assert (!log.contains("username"));
    assert (!log.contains("password"));

    logger.setLevel(Level.INFO);
    log = sreq.log("Info", true, Level.INFO);
    assert (log == null);

    logger.setLevel(level);

    byte[] bytes = sreq.getBytes();

    assert Request.getSequence(bytes) == 892403717;
    assert Request.getManagementServerId(bytes) == 3;
    assert Request.getAgentId(bytes) == 2;
    assert Request.getViaAgentId(bytes) == 2;
    Request creq = null;
    try {
      creq = Request.parse(bytes);
    } catch (ClassNotFoundException e) {
      s_logger.error("Unable to parse bytes: ", e);
    } catch (UnsupportedVersionException e) {
      s_logger.error("Unable to parse bytes: ", e);
    }

    assert creq != null : "Couldn't get the request back";

    compareRequest(creq, sreq);

    Answer ans = new Answer(cmd1, true, "No Problem");
    Response cresp = new Response(creq, ans);

    bytes = cresp.getBytes();

    Response sresp = null;
    try {
      sresp = Response.parse(bytes);
    } catch (ClassNotFoundException e) {
      s_logger.error("Unable to parse bytes: ", e);
    } catch (UnsupportedVersionException e) {
      s_logger.error("Unable to parse bytes: ", e);
    }

    assert sresp != null : "Couldn't get the response back";

    compareRequest(cresp, sresp);
  }