Beispiel #1
0
  public static void premain(String agentArgs, Instrumentation inst) throws FileNotFoundException {
    Config config = Config.readFromFile(Config.DEFAULT_FILE_CONFIG_LOCATION);
    globalInst = inst;

    inst.addTransformer(new BasicClassFileTransformer(config));

    ResourceMonitor rm = config.getResourceMonitor();
    if (rm.isActive() && hardwareThread == null) {
      //            installGCMonitoring();
      List<HardwareDaemonWriter> writers = new ArrayList<HardwareDaemonWriter>();

      if (rm.isDebug()) {
        System.out.println("use debug");
        writers.add(new HardwareDaemonWriterMockImpl());
      } else {
        System.out.println("not using debug");
      }
      if (rm.isSendToCollector())
        try {
          writers.add(new HardwareDaemonWriterCollectorImpl(config));
        } catch (IOException e) {
          e.printStackTrace();
        }
      hardwareThread = new HardwareDaemon(config, writers);
      hardwareThread.start();
    }
  }
Beispiel #2
0
 public SocketSender(Config config) throws IOException {
   super(new JsonConstruct());
   this.mCollectorHost = config.getCollector().getHost();
   this.mCollectorPort = config.getCollector().getPort();
   Socket socket = new Socket(mCollectorHost, mCollectorPort);
   OutputStream outputStream = socket.getOutputStream();
   mDataOutputStream =
       new ThreadLocal<BufferedWriter>() {
         @Override
         protected BufferedWriter initialValue() {
           return new BufferedWriter(new OutputStreamWriter(outputStream));
         };
       };
   isFlushOutput = config.getAgentConfig().isFlushOutput();
   debug = config.getAgentConfig().isDebug();
 }