Codota Logo
com.netflix.eureka.util
Code IndexAdd Codota to your IDE (free)

How to use com.netflix.eureka.util

Best Java code snippets using com.netflix.eureka.util (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Gson g =
  • Codota Iconnew Gson()
  • Codota IconGsonBuilder gsonBuilder;gsonBuilder.create()
  • Codota Iconnew GsonBuilder().create()
  • Smart code suggestions by Codota
}
origin: Netflix/eureka

/**
 * Increment the counter for the given statistic.
 */
public void increment() {
  increment(false);
}
origin: Netflix/eureka

private Builder() {
  result = new StatusInfo();
}
origin: Netflix/eureka

public static Builder newBuilder() {
  return new Builder();
}
origin: Netflix/eureka

public StatusInfo getStatusInfo() {
  StatusInfo.Builder builder = StatusInfo.Builder.newBuilder();
  // Add application level status
  int upReplicasCount = 0;
  StringBuilder upReplicas = new StringBuilder();
  StringBuilder downReplicas = new StringBuilder();
  StringBuilder replicaHostNames = new StringBuilder();
  for (PeerEurekaNode node : peerEurekaNodes.getPeerEurekaNodes()) {
    if (replicaHostNames.length() > 0) {
      replicaHostNames.append(", ");
    }
    replicaHostNames.append(node.getServiceUrl());
    if (isReplicaAvailable(node.getServiceUrl())) {
      upReplicas.append(node.getServiceUrl()).append(',');
      upReplicasCount++;
    } else {
      downReplicas.append(node.getServiceUrl()).append(',');
    }
  }
  builder.add("registered-replicas", replicaHostNames.toString());
  builder.add("available-replicas", upReplicas.toString());
  builder.add("unavailable-replicas", downReplicas.toString());
  
  // Only set the healthy flag if a threshold has been configured.
  if (peerEurekaNodes.getMinNumberOfAvailablePeers() > -1) {
    builder.isHealthy(upReplicasCount >= peerEurekaNodes.getMinNumberOfAvailablePeers());
  }
  builder.withInstanceInfo(this.instanceInfo);
  return builder.build();
}
origin: Netflix/eureka

@Test
public void testGetStatusInfoHealthy() {
  StatusUtil statusUtil = getStatusUtil(3, 3, 2);
  assertTrue(statusUtil.getStatusInfo().isHealthy());
}

origin: Netflix/eureka

/**
 * Register all statistics with <tt>Servo</tt>.
 */
public static void registerAllStats() {
  for (EurekaMonitors c : EurekaMonitors.values()) {
    Monitors.registerObject(c.getName(), c);
  }
}
origin: Netflix/eureka

@GET
public StatusInfo getStatusInfo() {
  return statusUtil.getStatusInfo();
}
origin: Netflix/eureka

@Inject
StatusResource(EurekaServerContext server) {
  this.statusUtil = new StatusUtil(server);
}
origin: Netflix/eureka

/**
 * Server context shutdown hook. Override for custom logic
 */
protected void destroyEurekaServerContext() throws Exception {
  EurekaMonitors.shutdown();
  if (awsBinder != null) {
    awsBinder.shutdown();
  }
  if (serverContext != null) {
    serverContext.shutdown();
  }
}
origin: Netflix/eureka

/**
 * Servo route; do not call.
 *
 * @return servo data
 */
@com.netflix.servo.annotations.Monitor(name = "numOfRenewsInLastMin",
    description = "Number of total heartbeats received in the last minute", type = DataSourceType.GAUGE)
@Override
public long getNumOfRenewsInLastMin() {
  return renewsLastMin.getCount();
}
origin: Netflix/eureka

protected void postInit() {
  renewsLastMin.start();
  if (evictionTaskRef.get() != null) {
    evictionTaskRef.get().cancel();
  }
  evictionTaskRef.set(new EvictionTask());
  evictionTimer.schedule(evictionTaskRef.get(),
      serverConfig.getEvictionIntervalTimerInMs(),
      serverConfig.getEvictionIntervalTimerInMs());
}
origin: Netflix/eureka

/**
 * Create a new, empty instance registry.
 */
protected AbstractInstanceRegistry(EurekaServerConfig serverConfig, EurekaClientConfig clientConfig, ServerCodecs serverCodecs) {
  this.serverConfig = serverConfig;
  this.clientConfig = clientConfig;
  this.serverCodecs = serverCodecs;
  this.recentCanceledQueue = new CircularQueue<Pair<Long, String>>(1000);
  this.recentRegisteredQueue = new CircularQueue<Pair<Long, String>>(1000);
  this.renewsLastMin = new MeasuredRate(1000 * 60 * 1);
  this.deltaRetentionTimer.schedule(getDeltaRetentionTask(),
      serverConfig.getDeltaRetentionTimerIntervalInMs(),
      serverConfig.getDeltaRetentionTimerIntervalInMs());
}
origin: Netflix/eureka

/**
 * Perform all cleanup and shutdown operations.
 */
@Override
public void shutdown() {
  deltaRetentionTimer.cancel();
  evictionTimer.cancel();
  renewsLastMin.stop();
}
origin: Netflix/eureka

@Test
public void testGetStatusInfoUnsetHealth() {
  StatusUtil statusUtil = getStatusUtil(5, 3, -1);
  StatusInfo statusInfo = statusUtil.getStatusInfo();
  
  try {
    statusInfo.isHealthy();
  } catch (NullPointerException e) {
    // Expected that the healthy flag is not set when the minimum value is -1
    return;
  }
  
  fail("Excpected NPE to be thrown when healthy threshold is not set");
}

origin: Netflix/eureka

  /**
   * Unregister all statistics from <tt>Servo</tt>.
   */
  public static void shutdown() {
    for (EurekaMonitors c : EurekaMonitors.values()) {
      DefaultMonitorRegistry.getInstance().unregister(Monitors.newObjectMonitor(c.getName(), c));
    }
  }
}
origin: Netflix/eureka

private void incrementStats(Target target) {
  if (serverConfig.isRateLimiterEnabled()) {
    EurekaMonitors.RATE_LIMITED.increment();
    if (target == Target.FullFetch) {
      EurekaMonitors.RATE_LIMITED_FULL_FETCH.increment();
    }
  } else {
    EurekaMonitors.RATE_LIMITED_CANDIDATES.increment();
    if (target == Target.FullFetch) {
      EurekaMonitors.RATE_LIMITED_FULL_FETCH_CANDIDATES.increment();
    }
  }
}
origin: Netflix/eureka

/**
 * Gets the number of <em>renewals</em> in the last minute.
 *
 * @return a long value representing the number of <em>renewals</em> in the last minute.
 */
@com.netflix.servo.annotations.Monitor(name = "numOfReplicationsInLastMin",
    description = "Number of total replications received in the last minute",
    type = com.netflix.servo.annotations.DataSourceType.GAUGE)
public long getNumOfReplicationsInLastMin() {
  return numberOfReplicationsLastMin.getCount();
}
origin: Netflix/eureka

@Override
public void init(PeerEurekaNodes peerEurekaNodes) throws Exception {
  this.numberOfReplicationsLastMin.start();
  this.peerEurekaNodes = peerEurekaNodes;
  initializedResponseCache();
  scheduleRenewalThresholdUpdateTask();
  initRemoteRegionRegistry();
  try {
    Monitors.registerObject(this);
  } catch (Throwable e) {
    logger.warn("Cannot register the JMX monitor for the InstanceRegistry :", e);
  }
}
origin: Netflix/eureka

@Inject
public PeerAwareInstanceRegistryImpl(
    EurekaServerConfig serverConfig,
    EurekaClientConfig clientConfig,
    ServerCodecs serverCodecs,
    EurekaClient eurekaClient
) {
  super(serverConfig, clientConfig, serverCodecs);
  this.eurekaClient = eurekaClient;
  this.numberOfReplicationsLastMin = new MeasuredRate(1000 * 60 * 1);
  // We first check if the instance is STARTING or DOWN, then we check explicit overrides,
  // then we check the status of a potentially existing lease.
  this.instanceStatusOverrideRule = new FirstMatchWinsCompositeRule(new DownOrStartingRule(),
      new OverrideExistsRule(overriddenInstanceStatusMap), new LeaseExistsRule());
}
origin: Netflix/eureka

@Test
public void testGetStatusInfoUnhealthy() {
  StatusUtil statusUtil = getStatusUtil(5, 3, 4);
  assertFalse(statusUtil.getStatusInfo().isHealthy());
}

com.netflix.eureka.util

Most used classes

  • StatusInfo
    An utility class for exposing status information of an instance.
  • EurekaMonitors
    The enum that encapsulates all statistics monitored by Eureka. Eureka Monitoring is done using Servo
  • StatusInfo$Builder
  • StatusUtil
  • AcceptorExecutor
    An active object with an internal thread accepting tasks from clients, and dispatching them to worke
  • TaskDispatchers,
  • TaskExecutors,
  • TaskHolder,
  • MeasuredRate,
  • AcceptorExecutor$AcceptorRunner,
  • TaskExecutors$BatchWorkerRunnable,
  • TaskExecutors$SingleTaskWorkerRunnable,
  • TaskExecutors$TaskExecutorMetrics,
  • TaskExecutors$WorkerRunnable,
  • TaskExecutors$WorkerRunnableFactory,
  • TaskProcessor,
  • TrafficShaper,
  • StatusUtilTest,
  • AcceptorExecutorTest
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now