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


Java Cache.getLogger方法代码示例

本文整理汇总了Java中com.gemstone.gemfire.cache.Cache.getLogger方法的典型用法代码示例。如果您正苦于以下问题:Java Cache.getLogger方法的具体用法?Java Cache.getLogger怎么用?Java Cache.getLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.gemstone.gemfire.cache.Cache的用法示例。


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

示例1: checkStatistics

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public static void checkStatistics() {
  try {
    Cache cache = CacheServerTestUtil.getCache();
    com.gemstone.gemfire.LogWriter logger = cache.getLogger();
    BridgeServerImpl currentServer = (BridgeServerImpl)(new ArrayList(cache
        .getBridgeServers()).get(0));
    AcceptorImpl ai = currentServer.getAcceptor();
    CacheClientNotifier notifier = ai.getCacheClientNotifier();
    CacheClientNotifierStats stats = notifier.getStats();
    logger.info("Stats:" + "\nDurableReconnectionCount:"
        + stats.get_durableReconnectionCount() + "\nQueueDroppedCount"
        + stats.get_queueDroppedCount()
        + "\nEventsEnqueuedWhileClientAwayCount"
        + stats.get_eventEnqueuedWhileClientAwayCount());
  }
  catch (Exception e) {
    fail("Exception thrown while executing checkStatistics()");
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:DurableClientStatsDUnitTest.java

示例2: checkStatisticsWithExpectedValues

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public static void checkStatisticsWithExpectedValues(int reconnectionCount,
    int queueDropCount, int enqueueCount) {
  try {
    Cache cache = CacheServerTestUtil.getCache();
    com.gemstone.gemfire.LogWriter logger = cache.getLogger();
    BridgeServerImpl currentServer = (BridgeServerImpl)(new ArrayList(cache
        .getBridgeServers()).get(0));
    AcceptorImpl ai = currentServer.getAcceptor();
    CacheClientNotifier notifier = ai.getCacheClientNotifier();
    CacheClientNotifierStats stats = notifier.getStats();
    logger.info("Stats:" + "\nDurableReconnectionCount:"
        + stats.get_durableReconnectionCount() + "\nQueueDroppedCount"
        + stats.get_queueDroppedCount()
        + "\nEventsEnqueuedWhileClientAwayCount"
        + stats.get_eventEnqueuedWhileClientAwayCount());
    assertEquals(reconnectionCount, stats.get_durableReconnectionCount());
    assertEquals(queueDropCount, stats.get_queueDroppedCount());
    assertEquals(enqueueCount, stats.get_eventEnqueuedWhileClientAwayCount());
  }
  catch (Exception e) {
    fail("Exception thrown while executing checkStatisticsWithExpectedValues()");
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:DurableClientStatsDUnitTest.java

示例3: prIndexCreationCheck

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public CacheSerializableRunnable prIndexCreationCheck(
    final String regionName, final String indexName, final int bucketCount)
{
  CacheSerializableRunnable sr = new CacheSerializableRunnable("pr IndexCreationCheck" + 
      regionName + " indexName :" + indexName) {
    public void run2()
    {
      //closeCache();
      Cache cache = getCache();
      LogWriter logger = cache.getLogger();
      PartitionedRegion region = (PartitionedRegion)cache.getRegion(regionName);
      Map indexMap = region.getIndex();
      PartitionedIndex index = (PartitionedIndex)region.getIndex().get(indexName);
      if (index == null) {
        fail("Index " + indexName + " Not Found for region " + regionName);
      }
      logger.info("Current number of buckets indexed : " + ""
          + ((PartitionedIndex)index).getNumberOfIndexedBuckets());        
      if (bucketCount >= 0) {
        waitForIndexedBuckets((PartitionedIndex)index, bucketCount);
      }
    }
  };
  return sr;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:26,代码来源:QueryIndexUsingXMLDUnitTest.java

示例4: indexCreationCheck

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public CacheSerializableRunnable indexCreationCheck(
    final String regionName, final String indexName)
{
  CacheSerializableRunnable sr = new CacheSerializableRunnable("IndexCreationCheck region: " + 
      regionName + " indexName :" + indexName) {
    public void run2()
    {
      //closeCache();
      Cache cache = getCache();
      LogWriter logger = cache.getLogger();
      LocalRegion region = (LocalRegion)cache.getRegion(regionName);
      Index index = region.getIndexManager().getIndex(indexName);
      if (index == null) {
        fail("Index " + indexName + " Not Found for region name:" + regionName);
      }
    }
  };
  return sr;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:QueryIndexUsingXMLDUnitTest.java

示例5: loadRegion

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public CacheSerializableRunnable loadRegion(
    final String name)
{
  CacheSerializableRunnable sr = new CacheSerializableRunnable("load region on " + name) {
    public void run2()
    {
      Cache cache = getCache();
      LogWriter logger = cache.getLogger();
      Region region = cache.getRegion(name);
      for (int i=0; i < 100; i++){
        region.put("" +i, new Portfolio(i));
      }        
    }
  };
  return sr;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:17,代码来源:QueryIndexUsingXMLDUnitTest.java

示例6: init

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
 * Initialize the <code>XmlAuthorization</code> callback for a client having
 * the given principal.
 * 
 * This method caches the full XML authorization file the first time it is
 * invoked and caches all the permissions for the provided
 * <code>principal</code> to speed up lookup the
 * <code>authorizeOperation</code> calls. The permissions for the principal
 * are maintained as a {@link Map} of region name to the {@link HashSet} of
 * operations allowed for that region. A global entry with region name as
 * empty string is also made for permissions provided for all the regions.
 * 
 * @param principal
 *                the principal associated with the authenticated client
 * @param cache
 *                reference to the cache object
 * @param remoteMember
 *                the {@link DistributedMember} object for the remote
 *                authenticated client
 * 
 * @throws NotAuthorizedException
 *                 if some exception condition happens during the
 *                 initialization while reading the XML; in such a case all
 *                 subsequent client operations will throw
 *                 <code>NotAuthorizedException</code>
 */
public void init(Principal principal, DistributedMember remoteMember,
    Cache cache) throws NotAuthorizedException {

  synchronized (sync) {
    XmlAuthorization.init(cache);
  }
  this.logger = cache.getLogger();
  this.securityLogger = cache.getSecurityLogger();

  String name;
  if (principal != null) {
    name = principal.getName();
  }
  else {
    name = EMPTY_VALUE;
  }
  HashSet<String> roles = XmlAuthorization.userRoles.get(name);
  if (roles != null) {
    for (String roleName : roles) {
      Map<String, Map<OperationCode, FunctionSecurityPrmsHolder>>
        regionOperationMap = XmlAuthorization.rolePermissions.get(roleName);
      if (regionOperationMap != null) {
        for (Map.Entry<String, Map<OperationCode, FunctionSecurityPrmsHolder>>
            regionEntry : regionOperationMap.entrySet()) {
          String regionName = regionEntry.getKey();
          Map<OperationCode, FunctionSecurityPrmsHolder> regionOperations =
            this.allowedOps.get(regionName);
          if (regionOperations == null) {
            regionOperations =
              new HashMap<OperationCode, FunctionSecurityPrmsHolder>();
            this.allowedOps.put(regionName, regionOperations);
          }
          regionOperations.putAll(regionEntry.getValue());
        }
      }
    }
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:65,代码来源:XmlAuthorization.java

示例7: getLogger

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected LogWriter getLogger() {
  if (logger == null) {
    Cache cache = CacheFactory.getAnyInstance();
    if (cache != null) {
      logger = cache.getLogger();
    } else {
      throw new IllegalStateException("Could not initialize logger");
    }
  }
  return logger;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:12,代码来源:AbstractCommand.java

示例8: getCacheSerializableRunnableForIndexCreationCheck

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public CacheSerializableRunnable getCacheSerializableRunnableForIndexCreationCheck(
    final String name)
{
  CacheSerializableRunnable prIndexCheck = new CacheSerializableRunnable(
      "PrIndexCreationCheck") {
    @Override
    public void run2()
    {
      //closeCache();
      Cache cache = getCache();
      LogWriter logger = cache.getLogger();
      PartitionedRegion region = (PartitionedRegion)cache.getRegion(name);
      Map indexMap = region.getIndex();
      Set indexSet = indexMap.entrySet();
      Iterator it = indexSet.iterator();
      while (it.hasNext()) {
        Map.Entry entry = (Map.Entry)it.next();
        Index index = (Index)entry.getValue();
        logger.info("the partitioned index created on this region "
            + " " + index);
        logger.info("Current number of buckets indexed : " + ""
            + ((PartitionedIndex)index).getNumberOfIndexedBuckets());
      }
      
      closeCache();
      disconnectFromDS();

    }
  };
  return prIndexCheck;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:32,代码来源:PRQueryDUnitHelper.java

示例9: raiseAlerts

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private void raiseAlerts() {
  int num = HydraUtil.getnextRandomInt(5);
  if(num==0)
    num++;
  Cache cache = CacheHelper.getCache();
  LogWriter writer = cache.getLogger();
  for(int i=0;i<num;i++){
    String message = "MSG" + System.nanoTime(); 
    writer.severe(message);
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:12,代码来源:PulseTestMBean.java

示例10: checkSystemAlert

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void checkSystemAlert(JMXOperations ops, ObjectName targetMbean){
  logInfo(prefix + " Calling checkSystemAlert");
  
  String url = ops.selectManagingNode();
  //targetMbean = ManagementUtil.getLocalMemberMBeanON();
  targetMbean = MBeanJMXAdapter.getDistributedSystemName();
  
  int dsId = (Integer) ops.getAttribute(url, targetMbean, "DistributedSystemId");
  String source = "DistributedSystem(" + dsId +")";
  InPlaceJMXNotifValidator validator = new InPlaceJMXNotifValidator("checkSystemAlert",targetMbean,url);
  String message = "MSG" + System.nanoTime(); 
  validator.expectationList.add(Expectations.
              forMBean(targetMbean).
              expectMBeanAt(url).
              expectNotification(ResourceNotification.SYSTEM_ALERT,
                  source,
                  message,
                  null,
                  Expectation.MATCH_NOTIFICATION_SOURCE_AND_MESSAGECONTAINS));
  
  Cache cache = CacheHelper.getCache();
  LogWriter writer = cache.getLogger();
  writer.severe(message);
  
  HydraUtil.sleepForReplicationJMX();
  
  validator.validateNotifications();
  
  logInfo(prefix + " Completed checkSystemAlert test successfully");    
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:31,代码来源:MemberTestMbean.java

示例11: selectWithType

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
@SuppressWarnings( { "unchecked" })
public QueryDataFunctionResult selectWithType(FunctionContext context, String queryString, boolean showMember,
    String regionName, int limit) throws Exception {

  LogWriter logger = null;
  Cache cache = CacheFactory.getAnyInstance();
  logger = cache.getLogger();

  Function loclQueryFunc = new LocalQueryFunction("LocalQueryFunction", regionName, showMember)
      .setOptimizeForWrite(true);

  queryString = applyLimitClause(queryString, limit);

  try {

    TypedJson result = new TypedJson();

    Region region = cache.getRegion(regionName);

    if (region == null) {
      throw new Exception(ManagementStrings.QUERY__MSG__REGIONS_NOT_FOUND_ON_MEMBER.toLocalizedString(regionName,
          cache.getDistributedSystem().getDistributedMember().getId()));
    }

    Object results = null;
    
    boolean noDataFound = true;

    if (region.getAttributes().getDataPolicy() == DataPolicy.NORMAL) {
      QueryService queryService = cache.getQueryService();

      Query query = queryService.newQuery(queryString);
      results = query.execute();

    } else {
      ResultCollector rcollector = FunctionService.onRegion(cache.getRegion(regionName)).withArgs(queryString)
          .execute(loclQueryFunc);
      List list = (List) rcollector.getResult();
      results = list.get(0);
    }

    if (results != null && results instanceof SelectResults) {

      SelectResults selectResults = (SelectResults) results;
      for (Iterator iter = selectResults.iterator(); iter.hasNext();) {
        Object object = iter.next();
        result.add(RESULT_KEY,object);
        noDataFound = false;
      }
    } else {
      result.add(RESULT_KEY,results);//TODO to confirm if there can be anything else apart from SelectResults
    }
    if (showMember) {
      result.add(MEMBER_KEY,cache.getDistributedSystem().getDistributedMember().getId());
    }

    if (noDataFound) {
     result.add(RESULT_KEY, NO_DATA_FOUND);
    }
    return new QueryDataFunctionResult(QUERY_EXEC_SUCCESS, BeanUtilFuncs.compress(result.toString()));
  } catch (Exception e) {
    logger.warning(e);
    throw e;
  } finally {

  }

}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:69,代码来源:QueryDataFunction.java

示例12: getQueryRegionsAssociatedMembers

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public static Set<DistributedMember> getQueryRegionsAssociatedMembers(
    Set<String> regions, final Cache cache, boolean returnAll) {
  LogWriter logger = cache.getLogger();
  Set<DistributedMember> members = null;
  Set<DistributedMember> newMembers = null;
  Iterator<String> iterator = regions.iterator();
  String region = (String) iterator.next();
  members = getRegionAssociatedMembers(region, cache, true);
  if (logger.fineEnabled())
    logger.fine("Members for region " + region + " Members " + members);
  List<String> regionAndingList = new ArrayList<String>();
  regionAndingList.add(region);
  if (regions.size() == 1) {
    newMembers = members;
  } else {
    if (members != null && !members.isEmpty()) {
      while (iterator.hasNext()) {
        region = iterator.next();
        newMembers = getRegionAssociatedMembers(region, cache, true);
        if (logger.fineEnabled())
          logger.fine("Members for region " + region + " Members "
              + newMembers);
        regionAndingList.add(region);
        newMembers.retainAll(members);
        members = newMembers;
        if (logger.fineEnabled())
          logger.fine("Members after anding for regions " + regionAndingList
              + " List : " + newMembers);
      }
    }
  }
  members = new HashSet<DistributedMember>();
  if (newMembers == null)
    return members;
  Iterator<DistributedMember> memberIterator = newMembers.iterator();
  while (memberIterator.hasNext()) {
    members.add(memberIterator.next());
    if (!returnAll) {
      return members;
    }
  }
  return members;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:44,代码来源:DataCommands.java

示例13: logError

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected static void logError(final Cache cache, final String message, final Throwable cause) {
  if (cache != null && cache.getLogger() != null) {
    cache.getLogger().error(message, cause);
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:6,代码来源:DescribeDiskStoreFunction.java

示例14: AbstractGatewaySender

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected AbstractGatewaySender(Cache cache, GatewaySenderAttributes attrs) {
  this.cache = cache;
  this.logger = (LogWriterI18n)cache.getLogger();
  this.id = attrs.getId();
  final StaticSystemCallbacks sysCb = GemFireCacheImpl
      .getInternalProductCallbacks();
  if (sysCb != null) {
    this.uuid = sysCb.getGatewayUUID(this, attrs);
  }
  else {
    // TODO: GemFire does not give UUIDs yet (need those for #48335)
    this.uuid = 0;
  }
  this.socketBufferSize = attrs.getSocketBufferSize();
  this.socketReadTimeout = attrs.getSocketReadTimeout();
  this.queueMemory = attrs.getMaximumQueueMemory();
  this.batchSize = attrs.getBatchSize();
  this.batchTimeInterval = attrs.getBatchTimeInterval();
  this.isConflation = attrs.isBatchConflationEnabled();
  this.isPersistence = attrs.isPersistenceEnabled();
  this.alertThreshold = attrs.getAlertThreshold();
  this.manualStart = attrs.isManualStart();
  this.isParallel = attrs.isParallel();
  this.isForInternalUse = attrs.isForInternalUse();
  this.diskStoreName = attrs.getDiskStoreName();
  this.remoteDSId = attrs.getRemoteDSId();
  this.eventFilters = attrs.getGatewayEventFilters();
  setOnlyGatewayEnqueueEventFiltersFlag();
  this.transFilters = attrs.getGatewayTransportFilters();
  this.listeners = attrs.getAsyncEventListeners();
  this.locatorDiscoveryCallback = attrs.getGatewayLocatoDiscoveryCallback();
  this.isDiskSynchronous = attrs.isDiskSynchronous();
  this.policy = attrs.getOrderPolicy();
  this.dispatcherThreads = attrs.getDispatcherThreads();
  this.parallelismForReplicatedRegion = attrs.getParallelismForReplicatedRegion();
  //divide the maximumQueueMemory of sender equally using number of dispatcher threads.
  //if dispatcherThreads is 1 then maxMemoryPerDispatcherQueue will be same as maximumQueueMemory of sender
  this.maxMemoryPerDispatcherQueue = this.queueMemory / this.dispatcherThreads;
  this.myDSId = InternalDistributedSystem.getAnyInstance().getDistributionManager().getDistributedSystemId();
  this.serialNumber = DistributionAdvisor.createSerialNumber();
  if (!(this.cache instanceof CacheCreation)) {
    this.stopper = new Stopper(cache.getCancelCriterion());
    this.senderAdvisor = GatewaySenderAdvisor.createGatewaySenderAdvisor(this, logger);
    if (!this.isForInternalUse()) {
      this.statistics = new GatewaySenderStats(cache.getDistributedSystem(),
          id);
    }
    else {// this sender lies underneath the AsyncEventQueue. Need to have
          // AsyncEventQueueStats
      this.statistics = new AsyncEventQueueStats(
          cache.getDistributedSystem(), AsyncEventQueueImpl
              .getAsyncEventQueueIdFromSenderId(id));
    }
  }
  this.isBucketSorted = attrs.isBucketSorted();
  this.isHDFSQueue = attrs.isHDFSQueue();
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:58,代码来源:AbstractGatewaySender.java

示例15: getCacheSerializableRunnableForIndexUsageCheck

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
   * Insure queries on a pr is using index if not fail.
   */
  public CacheSerializableRunnable getCacheSerializableRunnableForIndexUsageCheck(final String name) {
    SerializableRunnable PrIndexCheck = new CacheSerializableRunnable("PrIndexCheck") {
      @Override
      public void run2() {
        Cache cache = getCache();
        
//        Region parRegion = cache.getRegion(name);
        QueryService qs = cache.getQueryService();
        LogWriter logger = cache.getLogger();
      
          Collection indexes = qs.getIndexes();
          Iterator it = indexes.iterator();
          while(it.hasNext()) {         
            //logger.info("Following indexes found : " + it.next());
            PartitionedIndex ind = (PartitionedIndex)it.next();
            /*List bucketIndex = ind.getBucketIndexes();
            int k = 0;
            logger.info("Total number of bucket index : "+bucketIndex.size());
            while ( k < bucketIndex.size() ){
              Index bukInd = (Index)bucketIndex.get(k);
              logger.info("Buket Index "+bukInd+"  usage : "+bukInd.getStatistics().getTotalUses());
              // if number of quries on pr change in getCacheSerializableRunnableForPRQueryAndCompareResults
              // literal 6  should change.
              //Asif :  With the optmization of Range Queries a where clause
              // containing something like ID > 4 AND ID < 9 will be evaluated 
              //using a single index lookup, so accordingly modifying the 
              //assert value from 7 to 6
              // Anil : With aquiringReadLock during Index.getSizeEstimate(), the
              // Index usage in case of "ID = 0 OR ID = 1" is increased by 3.
              int indexUsageWithSizeEstimation = 3;
              int expectedUse = 6;
              long indexUse = bukInd.getStatistics().getTotalUses();
              // Anil : With chnages to use single index for PR query evaluation, once the index
              // is identified the same index is used on other PR buckets, the sieEstimation is
              // done only once, which adds additional index use for only one bucket index.
              if (!(indexUse == expectedUse || indexUse == (expectedUse + indexUsageWithSizeEstimation))){
                fail ("Index usage is not as expected, expected it to be either " + 
                    expectedUse + " or " + (expectedUse + indexUsageWithSizeEstimation) + 
                    " it is: " + indexUse);
                //assertEquals(6 + indexUsageWithSizeEstimation, bukInd.getStatistics().getTotalUses());
              }
              k++;
            }*/
            //Shobhit: Now we dont need to check stats per bucket index,
            //stats are accumulated in single pr index stats.
            
            // Anil : With aquiringReadLock during Index.getSizeEstimate(), the
            // Index usage in case of "ID = 0 OR ID = 1" is increased by 3.
            int indexUsageWithSizeEstimation = 3;
            
            logger.info("index uses for "+ind.getNumberOfIndexedBuckets()+" index "+ind.getName()+": "+ind.getStatistics().getTotalUses());
            assertEquals(6*ind.getNumberOfIndexedBuckets(), ind.getStatistics().getTotalUses());
          }
          
      }

          
      
    };
    return (CacheSerializableRunnable) PrIndexCheck;
  }
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:65,代码来源:PRQueryDUnitHelper.java


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