当前位置: 首页>>代码示例>>Java>>正文


Java Context类代码示例

本文整理汇总了Java中org.terracotta.management.model.context.Context的典型用法代码示例。如果您正苦于以下问题:Java Context类的具体用法?Java Context怎么用?Java Context使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Context类属于org.terracotta.management.model.context包,在下文中一共展示了Context类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clientDisconnected

import org.terracotta.management.model.context.Context; //导入依赖的package包/类
@Override
public synchronized void clientDisconnected(PlatformServer currentActive, PlatformConnectedClient platformConnectedClient) {
  LOGGER.trace("[0] clientDisconnected({})", platformConnectedClient);

  stripe.getServerByName(currentActive.getServerName())
      .ifPresent(server -> {

        ClientIdentifier clientIdentifier = toClientIdentifier(platformConnectedClient);
        cluster.getClient(clientIdentifier)
            .ifPresent(client -> {
              Context clientContext = client.getContext();

              client.remove();

              firingService.fireNotification(new ContextualNotification(server.getContext(), CLIENT_DISCONNECTED.name(), clientContext));
            });
      });
}
 
开发者ID:Terracotta-OSS,项目名称:terracotta-platform,代码行数:19,代码来源:TopologyService.java

示例2: willPushEntityStatistics

import org.terracotta.management.model.context.Context; //导入依赖的package包/类
/**
 * Records stats that needs to be sent in future (or now) when the entity will have arrived
 */
void willPushEntityStatistics(long consumerId, String serverName, ContextualStatistics... statistics) {
  // Stats are collected by the NMS entity collector so the consumer id calling willPushEntityStatistics
  // will be the consumer id of the NMS entity. Thus we have to retrieve the server entity thanks to the
  // context that is hold in the stat results
  Stream.of(statistics)
      .collect(Collectors.groupingBy(o -> Long.parseLong(o.getContext().getOrDefault(ServerEntity.CONSUMER_ID, String.valueOf(consumerId)))))
      .forEach((cid, cid_stats) -> whenServerEntity(cid, serverName).executeOrDiscard(serverEntity -> {
        Context context = serverEntity.getContext();
        for (ContextualStatistics statistic : cid_stats) {
          statistic.setContext(statistic.getContext().with(context));
        }
        LOGGER.trace("[{}] willPushEntityStatistics({}, {})", cid, serverName, cid_stats.size());
        firingService.fireStatistics(cid_stats.toArray(new ContextualStatistics[cid_stats.size()]));
      }));
}
 
开发者ID:Terracotta-OSS,项目名称:terracotta-platform,代码行数:19,代码来源:TopologyService.java

示例3: can_do_remote_diagnostic_calls_on_client

import org.terracotta.management.model.context.Context; //导入依赖的package包/类
@Test
public void can_do_remote_diagnostic_calls_on_client() throws Exception {
  Client client = nmsService.readTopology()
      .clientStream()
      .filter(e -> e.getName().equals("pet-clinic"))
      .findFirst()
      .get();

  // only the client id is necessary
  Context context = client.getContext();

  // thread dump
  String threadDump = nmsService.call(context, "DiagnosticCalls", "getThreadDump", String.class).waitForReturn();

  // typical strings in a thread dump :-)
  assertThat(threadDump, containsString("Full thread dump"));
  assertThat(threadDump, containsString("WAITING"));
  assertThat(threadDump, containsString("RUNNABLE"));
  assertThat(threadDump, containsString("at"));
}
 
开发者ID:Terracotta-OSS,项目名称:terracotta-platform,代码行数:21,代码来源:ClientCacheRemoteManagementIT.java

示例4: execute

import org.terracotta.management.model.context.Context; //导入依赖的package包/类
@Override
public ResultSet<ContextualStatistics> execute() {
  Map<Context, ContextualStatistics> contextualStatistics = new LinkedHashMap<Context, ContextualStatistics>(contexts.size());
  Collection<ManagementProvider<?>> managementProviders = capabilityManagement.getManagementProvidersByCapability(capabilityName);

  for (Context context : contexts) {
    Map<String, Statistic<? extends Serializable>> statistics = null;
    for (ManagementProvider<?> managementProvider : managementProviders) {
      if (managementProvider.supports(context)) {
        if (statistics == null) {
          statistics = managementProvider.collectStatistics(context, statisticNames);
        } else {
          statistics.putAll(managementProvider.collectStatistics(context, statisticNames));
        }
      }
    }
    contextualStatistics.put(context, new ContextualStatistics(capabilityName, context, statistics == null ? Collections.emptyMap() : statistics));
  }

  return new DefaultResultSet<>(contextualStatistics);
}
 
开发者ID:Terracotta-OSS,项目名称:terracotta-platform,代码行数:22,代码来源:DefaultStatisticQuery.java

示例5: ServerCacheExposedStatistics

import org.terracotta.management.model.context.Context; //导入依赖的package包/类
ServerCacheExposedStatistics(Context context, ServerCacheBinding binding, StatisticRegistry statisticRegistry) {
  super(context.with("type", "ServerCache"), binding, statisticRegistry);

  OperationStatisticDescriptor<CacheOperationOutcomes.GetOutcome> get = OperationStatisticDescriptor.descriptor("get", singleton("cluster"), CacheOperationOutcomes.GetOutcome.class);
  OperationStatisticDescriptor<CacheOperationOutcomes.PutOutcome> put = OperationStatisticDescriptor.descriptor("put", singleton("cluster"), CacheOperationOutcomes.PutOutcome.class);
  OperationStatisticDescriptor<CacheOperationOutcomes.ClearOutcome> clear = OperationStatisticDescriptor.descriptor("clear", singleton("cluster"), CacheOperationOutcomes.ClearOutcome.class);

  getStatisticRegistry().registerStatistic("Cluster:HitCount", get, of(CacheOperationOutcomes.GetOutcome.HIT));
  getStatisticRegistry().registerStatistic("Cluster:MissCount", get, of(CacheOperationOutcomes.GetOutcome.MISS));
  getStatisticRegistry().registerStatistic("Cluster:PutCount", put, of(CacheOperationOutcomes.PutOutcome.SUCCESS));
  getStatisticRegistry().registerStatistic("Cluster:ClearCount", clear, allOf(CacheOperationOutcomes.ClearOutcome.class));

  getStatisticRegistry().registerStatistic("Size", descriptor("size", singleton("cluster")));

  getStatisticRegistry().registerTable("Cluster:CacheEntryLength", () -> {
    Map<String, String> snapshot = binding.getValue().getData();
    return Table.newBuilder("KeyLength", "ValueLength")
        .withRows(snapshot.keySet(), (key, rowBuilder) -> rowBuilder
            .setStatistic("KeyLength", StatisticType.GAUGE, key.length())
            .setStatistic("ValueLength", StatisticType.COUNTER, snapshot.get(key).length()))
        .build();
  });
}
 
开发者ID:Terracotta-OSS,项目名称:terracotta-platform,代码行数:24,代码来源:ServerCacheStatisticsManagementProvider.java

示例6: queryStats

import org.terracotta.management.model.context.Context; //导入依赖的package包/类
private ContextualStatistics queryStats() {
  Context context = Context.empty()
      .with("cacheManagerName", "someCacheManager6")
      .with("cacheName", "someCache6");

  ResultSet<ContextualStatistics> executeQuery = managementRegistry.withCapability("StatisticsCapability")
      .queryAllStatistics()
      .on(context)
      .build()
      .execute();

  return executeQuery.getResult(context);
}
 
开发者ID:aurbroszniowski,项目名称:DevoxxFr2017,代码行数:14,代码来源:Ex6Service.java

示例7: queryStats

import org.terracotta.management.model.context.Context; //导入依赖的package包/类
private ContextualStatistics queryStats() {
  Context context = Context.empty()
      .with("cacheManagerName", "someCacheManager7")
      .with("cacheName", "someCache7");

  ResultSet<ContextualStatistics> executeQuery = managementRegistry.withCapability("StatisticsCapability")
      .queryAllStatistics()
      .on(context)
      .build()
      .execute();

  return executeQuery.getResult(context);
}
 
开发者ID:aurbroszniowski,项目名称:DevoxxFr2017,代码行数:14,代码来源:Ex7Service.java

示例8: queryStats

import org.terracotta.management.model.context.Context; //导入依赖的package包/类
private ContextualStatistics queryStats() {
  Context context = Context.empty()
      .with("cacheManagerName", "someCacheManager5")
      .with("cacheName", "someCache5");

  ResultSet<ContextualStatistics> executeQuery = managementRegistry.withCapability("StatisticsCapability")
      .queryAllStatistics()
      .on(context)
      .build()
      .execute();

  return executeQuery.getResult(context);
}
 
开发者ID:aurbroszniowski,项目名称:DevoxxFr2017,代码行数:14,代码来源:Ex5Service.java

示例9: queryStats

import org.terracotta.management.model.context.Context; //导入依赖的package包/类
private ContextualStatistics queryStats() {
  Context context = Context.empty()
      .with("cacheManagerName", "someCacheManager8")
      .with("cacheName", "someCache8");

  ResultSet<ContextualStatistics> executeQuery = managementRegistry.withCapability("StatisticsCapability")
      .queryAllStatistics()
      .on(context)
      .build()
      .execute();

  return executeQuery.getResult(context);
}
 
开发者ID:aurbroszniowski,项目名称:DevoxxFr2017,代码行数:14,代码来源:Ex8Service.java

示例10: sendManagementCallRequest

import org.terracotta.management.model.context.Context; //导入依赖的package包/类
@Override
public String sendManagementCallRequest(ClientDescriptor caller, final Context context, String capabilityName, String methodName, Class<?> returnType, Parameter... parameters) {
  LOGGER.trace("[{}] sendManagementCallRequest({}, {}, {})", consumerId, context, capabilityName, methodName);

  String managementCallIdentifier = UUID.randomUUID().toString();
  Context fullContext = null;

  if (context.contains(Client.KEY)) {
    // handle client call
    ClientIdentifier to = ClientIdentifier.valueOf(context.get(Client.KEY));
    fullContext = context.with(topologyService.getManageableClientContext(to)
        .orElseThrow(() -> new IllegalArgumentException("Client " + to + " is either not found or not manageable")));
  }

  if ((context.contains(Server.NAME_KEY) || context.contains(Server.KEY))
      && (context.contains(ServerEntity.CONSUMER_ID) || context.contains(ServerEntity.TYPE_KEY) && context.contains(ServerEntity.NAME_KEY))) {
    // handle entity call
    String serverName = context.getOrDefault(Server.NAME_KEY, context.get(Server.KEY));
    Context entityCtx = (context.contains(ServerEntity.CONSUMER_ID) ?
        topologyService.getManageableEntityContext(serverName, Long.parseLong(context.get(ServerEntity.CONSUMER_ID))) :
        topologyService.getManageableEntityContext(serverName, context.get(ServerEntity.NAME_KEY), context.get(ServerEntity.TYPE_KEY)))
        .orElseThrow(() -> new IllegalArgumentException("Server Entity " + context + " is either not found or not manageable"));
    fullContext = context.with(entityCtx);
  }

  if (fullContext == null) {
    // this method is called from an entity invoke, so throwing is OK
    throw new IllegalArgumentException(context.toString());
  }

  track(caller, managementCallIdentifier);

  firingService.fireManagementCallRequest(managementCallIdentifier, new ContextualCall<>(fullContext, capabilityName, methodName, returnType, parameters));

  return managementCallIdentifier;
}
 
开发者ID:Terracotta-OSS,项目名称:terracotta-platform,代码行数:37,代码来源:DefaultManagementService.java

示例11: onNotification

import org.terracotta.management.model.context.Context; //导入依赖的package包/类
@Override
public void onNotification(MessageSource messageSource, ContextualNotification notification) {
  accept(messageSource, "onNotification", () -> {
    // handles data coming from DefaultEntityMonitoringService.pushNotification()
    Context notificationContext = notification.getContext();
    long consumerId = messageSource.getConsumerId();
    if (notificationContext.contains(ServerEntity.CONSUMER_ID)) {
      consumerId = Long.parseLong(notificationContext.get(ServerEntity.CONSUMER_ID));
    }
    topologyService.willPushEntityNotification(consumerId, messageSource.getServerName(), notification);
  });
}
 
开发者ID:Terracotta-OSS,项目名称:terracotta-platform,代码行数:13,代码来源:DefaultManagementDataListener.java

示例12: addStatisticCollector

import org.terracotta.management.model.context.Context; //导入依赖的package包/类
@Override
public void addStatisticCollector(EntityManagementRegistry registry) {
  long consumerId = registry.getMonitoringService().getConsumerId();
  LOGGER.trace("[{}] addStatisticCollector()", consumerId);

  // The context for the collector is created from the the registry of the entity wanting server-side providers.
  // We create a provider that will receive management calls to control the global voltron's statistic collector.
  // This provider will thus be on top of the entity wanting to collect server-side stats
  ContextContainer contextContainer = registry.getContextContainer();
  Context context = Context.create(contextContainer.getName(), contextContainer.getValue());
  StatisticCollectorManagementProvider collectorManagementProvider = new StatisticCollectorManagementProvider(context);
  registry.addManagementProvider(collectorManagementProvider);

  EntityMonitoringService monitoringService = registry.getMonitoringService();

  StatisticCollector statisticCollector = new DefaultStatisticCollector(
      // Create a statistics collector which can collect stats over all management registries and only the registry combined.
      // This will avoid collecting stats on a registry from another NMS entity that already has its own stat collector.
      new CombiningCapabilityManagementSupport(sharedEntityManagementRegistry, registry),
      managementScheduler,
      list -> {
        // Add a marker on the statistics to know which statistics collector has collected them (from which NMS entity)
        list.forEach(stats -> stats.setContext(stats.getContext().with("collectorId", "" + consumerId)));
        monitoringService.pushStatistics(list.toArray(new ContextualStatistics[list.size()]));
      }
  );

  // add a collector service, not started by default, but that can be started through a remote management call
  registry.register(statisticCollector);

  registry.refresh();
}
 
开发者ID:Terracotta-OSS,项目名称:terracotta-platform,代码行数:33,代码来源:DefaultStatisticService.java

示例13: serverEntityDestroyed

import org.terracotta.management.model.context.Context; //导入依赖的package包/类
@Override
public synchronized void serverEntityDestroyed(PlatformServer sender, PlatformEntity platformEntity) {
  LOGGER.trace("[0] serverEntityDestroyed({}, {})", sender.getServerName(), platformEntity);

  if (platformEntity.isActive && !sender.getServerName().equals(getActiveServer().getServerName())) {
    Utils.warnOrAssert(LOGGER, "[0] serverEntityDestroyed({}, {}): Server is not current active server but it destroyed an active entity", sender.getServerName(), platformEntity);
    return;
  }

  if (!platformEntity.isActive && sender.getServerName().equals(getActiveServer().getServerName())) {
    Utils.warnOrAssert(LOGGER, "[0] serverEntityDestroyed({}, {}): Server is the current active server but it destroyed a passive entity", sender.getServerName(), platformEntity);
    return;
  }

  stripe.getServerByName(sender.getServerName()).ifPresent(server -> {
    server.getServerEntity(platformEntity.name, platformEntity.typeName).ifPresent(entity -> {
      Context context = entity.getContext();
      entity.remove();

      serverEntities.get(sender.getServerName()).remove(platformEntity.consumerID);

      if (isCurrentServerActive() && sender.getServerName().equals(currentActive.getServerName())) {
        entityFetches.remove(platformEntity.consumerID);
      }

      if (sender.getServerName().equals(getServerName())) {
        topologyEventListeners.forEach(listener -> listener.onEntityDestroyed(platformEntity.consumerID));
      }

      firingService.fireNotification(new ContextualNotification(context, SERVER_ENTITY_DESTROYED.name()));
    });
  });
}
 
开发者ID:Terracotta-OSS,项目名称:terracotta-platform,代码行数:34,代码来源:TopologyService.java

示例14: willPushClientStatistics

import org.terracotta.management.model.context.Context; //导入依赖的package包/类
/**
 * Records stats that needs to be sent in future (or now) when the client fetch info will have arrived
 */
void willPushClientStatistics(long consumerId, ClientDescriptor from, ContextualStatistics... statistics) {
  whenFetchClient(consumerId, from).executeOrDiscard(client -> {
    Context context = client.getContext();
    for (ContextualStatistics statistic : statistics) {
      statistic.setContext(statistic.getContext().with(context));
    }
    LOGGER.trace("[{}] willPushClientStatistics({}, {})", consumerId, from, statistics.length);
    firingService.fireStatistics(statistics);
  });
}
 
开发者ID:Terracotta-OSS,项目名称:terracotta-platform,代码行数:14,代码来源:TopologyService.java

示例15: willPushClientNotification

import org.terracotta.management.model.context.Context; //导入依赖的package包/类
/**
 * Records notification that needs to be sent in future (or now) when the client fetch info will have arrived
 */
void willPushClientNotification(long consumerId, ClientDescriptor from, ContextualNotification notification) {
  whenFetchClient(consumerId, from).executeOrDelay(client -> {
    Context context = client.getContext();
    notification.setContext(notification.getContext().with(context));
    LOGGER.trace("[{}] willPushClientNotification({}, {})", consumerId, from, notification);
    firingService.fireNotification(notification);
  });
}
 
开发者ID:Terracotta-OSS,项目名称:terracotta-platform,代码行数:12,代码来源:TopologyService.java


注:本文中的org.terracotta.management.model.context.Context类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。