test_class.file: proxy/src/test/java/com/wavefront/agent/ProxyCheckInSchedulerTest.java
test_class.identifier: ProxyCheckInSchedulerTest
test_case.body: @Test
    public void testNetworkErrors() {
      ProxyConfig proxyConfig = EasyMock.createMock(ProxyConfig.class);
      ProxyV2API proxyV2API = EasyMock.createMock(ProxyV2API.class);
      APIContainer apiContainer = EasyMock.createMock(APIContainer.class);
      reset(proxyConfig, proxyV2API, proxyConfig);
      expect(proxyConfig.getServer()).andReturn("https://acme.corp/zzz").anyTimes();
      expect(proxyConfig.getToken()).andReturn("abcde12345").anyTimes();
      expect(proxyConfig.getHostname()).andReturn("proxyHost").anyTimes();
      expect(proxyConfig.isEphemeral()).andReturn(true).anyTimes();
      expect(proxyConfig.getAgentMetricsPointTags()).andReturn(Collections.emptyMap()).anyTimes();
      String authHeader = "Bearer abcde12345";
      AgentConfiguration returnConfig = new AgentConfiguration();
      returnConfig.setPointsPerBatch(1234567L);
      replay(proxyConfig);
      UUID proxyId = ProxyUtil.getOrCreateProxyId(proxyConfig);
      expect(apiContainer.getProxyV2API()).andReturn(proxyV2API).anyTimes();
      expect(proxyV2API.proxyCheckin(eq(proxyId), eq(authHeader), eq("proxyHost"),
          eq(getBuildVersion()), anyLong(), anyObject(), eq(true))).
          andThrow(new ProcessingException(new UnknownHostException())).once();
      expect(proxyV2API.proxyCheckin(eq(proxyId), eq(authHeader), eq("proxyHost"),
          eq(getBuildVersion()), anyLong(), anyObject(), eq(true))).
          andThrow(new ProcessingException(new SocketTimeoutException())).once();
      expect(proxyV2API.proxyCheckin(eq(proxyId), eq(authHeader), eq("proxyHost"),
          eq(getBuildVersion()), anyLong(), anyObject(), eq(true))).
          andThrow(new ProcessingException(new ConnectException())).once();
      expect(proxyV2API.proxyCheckin(eq(proxyId), eq(authHeader), eq("proxyHost"),
          eq(getBuildVersion()), anyLong(), anyObject(), eq(true))).
          andThrow(new ProcessingException(new NullPointerException())).once();
      expect(proxyV2API.proxyCheckin(eq(proxyId), eq(authHeader), eq("proxyHost"),
          eq(getBuildVersion()), anyLong(), anyObject(), eq(true))).
          andThrow(new NullPointerException()).once();
  
      replay(proxyV2API, apiContainer);
      ProxyCheckInScheduler scheduler = new ProxyCheckInScheduler(proxyId, proxyConfig, apiContainer,
          x -> fail("We are not supposed to get here"), () -> {});
      scheduler.updateConfiguration();
      scheduler.updateConfiguration();
      scheduler.updateConfiguration();
      scheduler.updateConfiguration();
      verify(proxyConfig, proxyV2API, apiContainer);
    }
test_case.class_method_signature: ProxyCheckInSchedulerTest.testNetworkErrors()
test_case.full_signature: @Test public void testNetworkErrors()
test_case.identifier: testNetworkErrors
test_case.invocations: createMock createMock createMock reset anyTimes andReturn expect getServer anyTimes andReturn expect getToken anyTimes andReturn expect getHostname anyTimes andReturn expect isEphemeral anyTimes andReturn expect getAgentMetricsPointTags emptyMap setPointsPerBatch replay getOrCreateProxyId anyTimes andReturn expect getProxyV2API once andThrow expect proxyCheckin eq eq eq eq getBuildVersion anyLong anyObject eq once andThrow expect proxyCheckin eq eq eq eq getBuildVersion anyLong anyObject eq once andThrow expect proxyCheckin eq eq eq eq getBuildVersion anyLong anyObject eq once andThrow expect proxyCheckin eq eq eq eq getBuildVersion anyLong anyObject eq once andThrow expect proxyCheckin eq eq eq eq getBuildVersion anyLong anyObject eq replay fail updateConfiguration updateConfiguration updateConfiguration updateConfiguration verify
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testNetworkErrors()
focal_class.declarator: logger = Logger.getLogger("proxy")
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = Logger.getLogger("proxy");
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: MAX_CHECKIN_ATTEMPTS = 5
focal_class.modifier: private static final
focal_class.original_string: private static final int MAX_CHECKIN_ATTEMPTS = 5;
focal_class.type: int
focal_class.var_name: MAX_CHECKIN_ATTEMPTS
focal_class.declarator: ID = Integer.toHexString((int) (Math.random() * Integer.MAX_VALUE))
focal_class.modifier: private static final
focal_class.original_string: private static final String ID = Integer.toHexString((int) (Math.random() * Integer.MAX_VALUE));
focal_class.type: String
focal_class.var_name: ID
focal_class.declarator: proxyId
focal_class.modifier: private final
focal_class.original_string: private final UUID proxyId;
focal_class.type: UUID
focal_class.var_name: proxyId
focal_class.declarator: proxyConfig
focal_class.modifier: private final
focal_class.original_string: private final ProxyConfig proxyConfig;
focal_class.type: ProxyConfig
focal_class.var_name: proxyConfig
focal_class.declarator: apiContainer
focal_class.modifier: private final
focal_class.original_string: private final APIContainer apiContainer;
focal_class.type: APIContainer
focal_class.var_name: apiContainer
focal_class.declarator: agentConfigurationConsumer
focal_class.modifier: private final
focal_class.original_string: private final Consumer<AgentConfiguration> agentConfigurationConsumer;
focal_class.type: Consumer<AgentConfiguration>
focal_class.var_name: agentConfigurationConsumer
focal_class.declarator: shutdownHook
focal_class.modifier: private final
focal_class.original_string: private final Runnable shutdownHook;
focal_class.type: Runnable
focal_class.var_name: shutdownHook
focal_class.declarator: serverEndpointUrl = null
focal_class.modifier: private
focal_class.original_string: private String serverEndpointUrl = null;
focal_class.type: String
focal_class.var_name: serverEndpointUrl
focal_class.declarator: agentMetrics
focal_class.modifier: private volatile
focal_class.original_string: private volatile JsonNode agentMetrics;
focal_class.type: JsonNode
focal_class.var_name: agentMetrics
focal_class.declarator: retries = new AtomicInteger(0)
focal_class.modifier: private final
focal_class.original_string: private final AtomicInteger retries = new AtomicInteger(0);
focal_class.type: AtomicInteger
focal_class.var_name: retries
focal_class.declarator: successfulCheckIns = new AtomicLong(0)
focal_class.modifier: private final
focal_class.original_string: private final AtomicLong successfulCheckIns = new AtomicLong(0);
focal_class.type: AtomicLong
focal_class.var_name: successfulCheckIns
focal_class.declarator: retryImmediately = false
focal_class.modifier: private
focal_class.original_string: private boolean retryImmediately = false;
focal_class.type: boolean
focal_class.var_name: retryImmediately
focal_class.declarator: executor = Executors.
        newScheduledThreadPool(2, new NamedThreadFactory("proxy-configuration"))
focal_class.modifier: private final
focal_class.original_string: private final ScheduledExecutorService executor = Executors.
        newScheduledThreadPool(2, new NamedThreadFactory("proxy-configuration"));
focal_class.type: ScheduledExecutorService
focal_class.var_name: executor
focal_class.file: proxy/src/main/java/com/wavefront/agent/ProxyCheckInScheduler.java
focal_class.identifier: ProxyCheckInScheduler
focal_class.class_method_signature: ProxyCheckInScheduler.ProxyCheckInScheduler(UUID proxyId,
                                 ProxyConfig proxyConfig,
                                 APIContainer apiContainer,
                                 Consumer<AgentConfiguration> agentConfigurationConsumer,
                                 Runnable shutdownHook)
focal_class.full_signature: public  ProxyCheckInScheduler(UUID proxyId,
                                 ProxyConfig proxyConfig,
                                 APIContainer apiContainer,
                                 Consumer<AgentConfiguration> agentConfigurationConsumer,
                                 Runnable shutdownHook)
focal_class.identifier: ProxyCheckInScheduler
focal_class.modifiers: public
focal_class.parameters: (UUID proxyId,
                                 ProxyConfig proxyConfig,
                                 APIContainer apiContainer,
                                 Consumer<AgentConfiguration> agentConfigurationConsumer,
                                 Runnable shutdownHook)
focal_class.signature:  ProxyCheckInScheduler(UUID proxyId,
                                 ProxyConfig proxyConfig,
                                 APIContainer apiContainer,
                                 Consumer<AgentConfiguration> agentConfigurationConsumer,
                                 Runnable shutdownHook)
focal_class.class_method_signature: ProxyCheckInScheduler.scheduleCheckins()
focal_class.full_signature: public void scheduleCheckins()
focal_class.identifier: scheduleCheckins
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void scheduleCheckins()
focal_class.class_method_signature: ProxyCheckInScheduler.getSuccessfulCheckinCount()
focal_class.full_signature: public long getSuccessfulCheckinCount()
focal_class.identifier: getSuccessfulCheckinCount
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getSuccessfulCheckinCount()
focal_class.class_method_signature: ProxyCheckInScheduler.shutdown()
focal_class.full_signature: public void shutdown()
focal_class.identifier: shutdown
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void shutdown()
focal_class.class_method_signature: ProxyCheckInScheduler.checkin()
focal_class.full_signature: private AgentConfiguration checkin()
focal_class.identifier: checkin
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: AgentConfiguration
focal_class.signature: AgentConfiguration checkin()
focal_class.class_method_signature: ProxyCheckInScheduler.updateConfiguration()
focal_class.full_signature: @VisibleForTesting void updateConfiguration()
focal_class.identifier: updateConfiguration
focal_class.modifiers: @VisibleForTesting
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void updateConfiguration()
focal_class.class_method_signature: ProxyCheckInScheduler.updateProxyMetrics()
focal_class.full_signature: @VisibleForTesting void updateProxyMetrics()
focal_class.identifier: updateProxyMetrics
focal_class.modifiers: @VisibleForTesting
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void updateProxyMetrics()
focal_class.class_method_signature: ProxyCheckInScheduler.checkinError(String errMsg)
focal_class.full_signature: private void checkinError(String errMsg)
focal_class.identifier: checkinError
focal_class.modifiers: private
focal_class.parameters: (String errMsg)
focal_class.return: void
focal_class.signature: void checkinError(String errMsg)
focal_method.body: @VisibleForTesting
    void updateConfiguration() {
      try {
        AgentConfiguration config = checkin();
        if (config != null) {
          if (config.getShutOffAgents()) {
            logger.severe(firstNonNull(config.getShutOffMessage(),
                "Shutting down: Server side flag indicating proxy has to shut down."));
            shutdownHook.run();
          } else {
            agentConfigurationConsumer.accept(config);
          }
        }
      } catch (Exception e) {
        logger.log(Level.SEVERE, "Exception occurred during configuration update", e);
      }
    }
focal_method.class_method_signature: ProxyCheckInScheduler.updateConfiguration()
focal_method.full_signature: @VisibleForTesting void updateConfiguration()
focal_method.identifier: updateConfiguration
focal_method.invocations: checkin getShutOffAgents severe firstNonNull getShutOffMessage run accept log
focal_method.modifiers: @VisibleForTesting
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void updateConfiguration()