Exemple #1
0
  /** Starts a peer that uses an already connected socket. */
  public NativeAgentPeer(
      TODConfig aConfig,
      Socket aSocket,
      String aStructureDatabaseId,
      IInstrumenter aInstrumenter,
      int aHostId) {
    super(aSocket, false);
    assert aConfig != null;
    itsConfig = aConfig;
    itsStructureDatabaseId = aStructureDatabaseId;
    itsInstrumenter = aInstrumenter;
    itsHostId = aHostId;

    String theStoreClassesDir = itsConfig.get(TODConfig.INSTRUMENTER_CLASSES_DIR);
    itsStoreClassesDir =
        theStoreClassesDir != null && theStoreClassesDir.length() > 0
            ? new File(theStoreClassesDir)
            : null;

    // Check that the cache path we pass to the agent exists.
    File theFile = new File(itsConfig.get(TODConfig.AGENT_CACHE_PATH));
    theFile.mkdirs();

    start();
  }
Exemple #2
0
  /**
   * Sends configuration data to the agent. This method is called once at the beginning of the
   * connection.
   */
  private void processConfig(DataInputStream aInputStream, DataOutputStream aOutputStream)
      throws IOException {
    DataInputStream theInStream = new DataInputStream(aInputStream);
    DataOutputStream theOutStream = new DataOutputStream(aOutputStream);

    // Read host name
    itsHostName = theInStream.readUTF();
    System.out.println("[NativeAgentPeer] Received host name: '" + itsHostName + "'");

    itsUseJava14 = theInStream.readByte() != 0;

    // Send host id
    theOutStream.writeInt(itsHostId);

    // Send remaining config
    boolean theSkipCoreClasses = itsConfig.get(TODConfig.AGENT_SKIP_CORE_CLASSE);
    theOutStream.writeByte(SET_SKIP_CORE_CLASSES);
    theOutStream.writeByte(theSkipCoreClasses ? 1 : 0);

    boolean theCaptureExceptions = itsConfig.get(TODConfig.AGENT_CAPTURE_EXCEPTIONS);
    theOutStream.writeByte(SET_CAPTURE_EXCEPTIONS);
    theOutStream.writeByte(theCaptureExceptions ? 1 : 0);

    int theHostBits = AgentConfig.HOST_BITS;
    theOutStream.writeByte(SET_HOST_BITS);
    theOutStream.writeByte(theHostBits);

    String theWorkingSet = itsConfig.get(TODConfig.SCOPE_TRACE_FILTER);
    theOutStream.writeByte(SET_WORKINGSET);
    theOutStream.writeUTF(theWorkingSet);

    theOutStream.writeByte(SET_STRUCTDB_ID);
    theOutStream.writeUTF(itsStructureDatabaseId);

    // Special cases working set
    StringBuilder theSCWS = new StringBuilder("[");
    for (String theName : itsInstrumenter.getSpecialCaseClasses()) {
      theSCWS.append(" +");
      theSCWS.append(theName);
    }
    theSCWS.append(']');
    theOutStream.writeByte(SET_SPECIALCASE_WORKINGSET);
    theOutStream.writeUTF(theSCWS.toString());

    // Finish
    theOutStream.writeByte(CONFIG_DONE);
    theOutStream.flush();
  }