當前位置: 首頁>>代碼示例>>Java>>正文


Java Context.with方法代碼示例

本文整理匯總了Java中org.terracotta.management.model.context.Context.with方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.with方法的具體用法?Java Context.with怎麽用?Java Context.with使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.terracotta.management.model.context.Context的用法示例。


在下文中一共展示了Context.with方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: getContext

import org.terracotta.management.model.context.Context; //導入方法依賴的package包/類
@Override
public Context getContext() {
  Context context = super.getContext()
      .with(NAME_KEY, getName())
      .with(TYPE_KEY, getType());
  if (consumerId > 0) {
    context = context.with(CONSUMER_ID, String.valueOf(consumerId));
  }
  return context;
}
 
開發者ID:Terracotta-OSS,項目名稱:terracotta-platform,代碼行數:11,代碼來源:ServerEntity.java

示例4: call

import org.terracotta.management.model.context.Context; //導入方法依賴的package包/類
@Override
public Future<String> call(@ClientId Object callerDescriptor, Context context, String capabilityName, String methodName, Class<?> returnType, Parameter... parameters) {
  if (context.contains(Stripe.KEY)) {
    context = context.with(Stripe.KEY, "SINGLE");
  }
  return CompletableFuture.completedFuture(managementService.sendManagementCallRequest((ClientDescriptor) callerDescriptor, context, capabilityName, methodName, returnType, parameters));
}
 
開發者ID:Terracotta-OSS,項目名稱:terracotta-platform,代碼行數:8,代碼來源:ActiveNmsServerEntity.java

示例5: ExposedServerCacheBinding

import org.terracotta.management.model.context.Context; //導入方法依賴的package包/類
ExposedServerCacheBinding(Context context, ServerCacheBinding binding) {
  super(context.with("type", "ServerCache"), binding);
}
 
開發者ID:Terracotta-OSS,項目名稱:terracotta-platform,代碼行數:4,代碼來源:ServerCacheSettingsManagementProvider.java

示例6: ExposedClientStateBinding

import org.terracotta.management.model.context.Context; //導入方法依賴的package包/類
ExposedClientStateBinding(Context context, ClientStateBinding clientBinding) {
  super(context.with("type", "ClientState"), clientBinding);
}
 
開發者ID:Terracotta-OSS,項目名稱:terracotta-platform,代碼行數:4,代碼來源:ClientStateSettingsManagementProvider.java

示例7: OffHeapResourceBindingExposedStatistics

import org.terracotta.management.model.context.Context; //導入方法依賴的package包/類
OffHeapResourceBindingExposedStatistics(Context context, OffHeapResourceBinding binding, StatisticRegistry statisticRegistry) {
  super(context.with("type", "OffHeapResource"), binding, statisticRegistry);

  getStatisticRegistry().registerStatistic("AllocatedMemory", descriptor("allocatedMemory", "tier", "OffHeapResource"));
}
 
開發者ID:Terracotta-OSS,項目名稱:terracotta-platform,代碼行數:6,代碼來源:OffHeapResourceStatisticsManagementProvider.java

示例8: ExposedOffHeapResourceBinding

import org.terracotta.management.model.context.Context; //導入方法依賴的package包/類
ExposedOffHeapResourceBinding(Context context, OffHeapResourceBinding binding) {
  super(context.with("type", "OffHeapResource"), binding);
}
 
開發者ID:Terracotta-OSS,項目名稱:terracotta-platform,代碼行數:4,代碼來源:OffHeapResourceSettingsManagementProvider.java


注:本文中的org.terracotta.management.model.context.Context.with方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。