Пример #1
0
 private void gc() throws Exception {
   sendRequest(
       ServerRequest.newBuilder()
           .setRequestId(nextRequestId.getAndIncrement())
           .setGcRequest(GcRequest.getDefaultInstance())
           .build());
 }
Пример #2
0
 private void preloadClasspathCache() throws Exception {
   sendRequest(
       ServerRequest.newBuilder()
           .setRequestId(nextRequestId.getAndIncrement())
           .setPreloadClasspathCacheRequest(PreloadClasspathCacheRequest.getDefaultInstance())
           .build());
 }
Пример #3
0
 private void updateAgentConfig(AgentConfig agentConfig) throws Exception {
   sendRequest(
       ServerRequest.newBuilder()
           .setRequestId(nextRequestId.getAndIncrement())
           .setAgentConfigUpdateRequest(
               AgentConfigUpdateRequest.newBuilder().setAgentConfig(agentConfig))
           .build());
 }
Пример #4
0
 private List<Trace.Entry> getEntries(String traceId) throws Exception {
   ClientResponse response =
       sendRequest(
           ServerRequest.newBuilder()
               .setRequestId(nextRequestId.getAndIncrement())
               .setEntriesRequest(EntriesRequest.newBuilder().setTraceId(traceId))
               .build());
   return response.getEntriesResponse().getEntryList();
 }
Пример #5
0
 private int reweave() throws Exception {
   ClientResponse response =
       sendRequest(
           ServerRequest.newBuilder()
               .setRequestId(nextRequestId.getAndIncrement())
               .setReweaveRequest(ReweaveRequest.getDefaultInstance())
               .build());
   return response.getReweaveResponse().getClassUpdateCount();
 }
Пример #6
0
 private GlobalMeta globalMeta() throws Exception {
   ClientResponse response =
       sendRequest(
           ServerRequest.newBuilder()
               .setRequestId(nextRequestId.getAndIncrement())
               .setGlobalMetaRequest(GlobalMetaRequest.getDefaultInstance())
               .build());
   return response.getGlobalMetaResponse().getGlobalMeta();
 }
Пример #7
0
 private MBeanMeta mbeanMeta(String objectName) throws Exception {
   ClientResponse response =
       sendRequest(
           ServerRequest.newBuilder()
               .setRequestId(nextRequestId.getAndIncrement())
               .setMbeanMetaRequest(MBeanMetaRequest.newBuilder().setObjectName(objectName))
               .build());
   return response.getMbeanMetaResponse().getMbeanMeta();
 }
Пример #8
0
 private HeapDumpFileInfo heapDump(String directory) throws Exception {
   ClientResponse response =
       sendRequest(
           ServerRequest.newBuilder()
               .setRequestId(nextRequestId.getAndIncrement())
               .setHeapDumpRequest(HeapDumpRequest.newBuilder().setDirectory(directory))
               .build());
   return response.getHeapDumpResponse().getHeapDumpFileInfo();
 }
Пример #9
0
 private ThreadDump threadDump() throws Exception {
   ClientResponse response =
       sendRequest(
           ServerRequest.newBuilder()
               .setRequestId(nextRequestId.getAndIncrement())
               .setThreadDumpRequest(ThreadDumpRequest.getDefaultInstance())
               .build());
   return response.getThreadDumpResponse().getThreadDump();
 }
Пример #10
0
 private Capabilities capabilities() throws Exception {
   ClientResponse response =
       sendRequest(
           ServerRequest.newBuilder()
               .setRequestId(nextRequestId.getAndIncrement())
               .setCapabilitiesRequest(CapabilitiesRequest.getDefaultInstance())
               .build());
   return response.getCapabilitiesResponse().getCapabilities();
 }
Пример #11
0
 private long availableDiskSpaceBytes(String directory) throws Exception {
   ClientResponse response =
       sendRequest(
           ServerRequest.newBuilder()
               .setRequestId(nextRequestId.getAndIncrement())
               .setAvailableDiskSpaceRequest(
                   AvailableDiskSpaceRequest.newBuilder().setDirectory(directory))
               .build());
   return response.getAvailableDiskSpaceResponse().getAvailableBytes();
 }
Пример #12
0
 private List<String> matchingClassNames(String partialClassName, int limit) throws Exception {
   ClientResponse response =
       sendRequest(
           ServerRequest.newBuilder()
               .setRequestId(nextRequestId.getAndIncrement())
               .setMatchingClassNamesRequest(
                   MatchingClassNamesRequest.newBuilder()
                       .setPartialClassName(partialClassName)
                       .setLimit(limit))
               .build());
   return response.getMatchingClassNamesResponse().getClassNameList();
 }
Пример #13
0
 private List<MethodSignature> methodSignatures(String className, String methodName)
     throws Exception {
   ClientResponse response =
       sendRequest(
           ServerRequest.newBuilder()
               .setRequestId(nextRequestId.getAndIncrement())
               .setMethodSignaturesRequest(
                   MethodSignaturesRequest.newBuilder()
                       .setClassName(className)
                       .setMethodName(methodName))
               .build());
   return response.getMethodSignaturesResponse().getMethodSignatureList();
 }
Пример #14
0
 private MBeanDump mbeanDump(MBeanDumpKind mbeanDumpKind, List<String> objectNames)
     throws Exception {
   ClientResponse response =
       sendRequest(
           ServerRequest.newBuilder()
               .setRequestId(nextRequestId.getAndIncrement())
               .setMbeanDumpRequest(
                   MBeanDumpRequest.newBuilder()
                       .setKind(mbeanDumpKind)
                       .addAllObjectName(objectNames))
               .build());
   return response.getMbeanDumpResponse().getMbeanDump();
 }
Пример #15
0
 private @Nullable Trace getFullTrace(String traceId) throws Exception {
   ClientResponse response =
       sendRequest(
           ServerRequest.newBuilder()
               .setRequestId(nextRequestId.getAndIncrement())
               .setFullTraceRequest(FullTraceRequest.newBuilder().setTraceId(traceId))
               .build());
   if (response.getFullTraceResponse().hasTrace()) {
     return response.getFullTraceResponse().getTrace();
   } else {
     return null;
   }
 }
Пример #16
0
 private ClientResponse sendRequest(ServerRequest request) throws Exception {
   ResponseHolder responseHolder = new ResponseHolder();
   responseHolders.put(request.getRequestId(), responseHolder);
   requestObserver.onNext(request);
   // timeout is in case agent never responds
   // passing ClientResponse.getDefaultInstance() is just dummy (non-null) value
   ClientResponse response =
       responseHolder.response.exchange(ClientResponse.getDefaultInstance(), 1, HOURS);
   if (response.getMessageCase() == MessageCase.UNKNOWN_REQUEST_RESPONSE) {
     throw new OutdatedAgentException();
   }
   if (response.getMessageCase() == MessageCase.EXCEPTION_RESPONSE) {
     throw new AgentException();
   }
   return response;
 }
Пример #17
0
 @Override
 public void onNext(ClientResponse value) {
   if (value.getMessageCase() == MessageCase.HELLO) {
     agentId = value.getHello().getAgentId();
     connectedAgents.put(agentId, ConnectedAgent.this);
     requestObserver.onNext(
         ServerRequest.newBuilder().setHelloAck(HelloAck.getDefaultInstance()).build());
     return;
   }
   long requestId = value.getRequestId();
   ResponseHolder responseHolder = responseHolders.getIfPresent(requestId);
   responseHolders.invalidate(requestId);
   if (responseHolder == null) {
     logger.error("no response holder for request id: {}", requestId);
     return;
   }
   try {
     responseHolder.response.exchange(value);
   } catch (InterruptedException e) {
     Thread.currentThread().interrupt();
     logger.error(e.getMessage(), e);
   }
 }