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


Java RemovalCause类代码示例

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


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

示例1: init

import com.google.common.cache.RemovalCause; //导入依赖的package包/类
@Override
public void init(DeviceId deviceId, PipelinerContext context) {
    this.serviceDirectory = context.directory();
    this.deviceId = deviceId;

    flowRuleService = serviceDirectory.get(FlowRuleService.class);
    flowObjectiveStore = serviceDirectory.get(FlowObjectiveStore.class);

    pendingNext = CacheBuilder.newBuilder()
            .expireAfterWrite(20, TimeUnit.SECONDS)
            .removalListener((RemovalNotification<Integer, NextObjective> notification) -> {
                if (notification.getCause() == RemovalCause.EXPIRED) {
                    notification.getValue().context()
                            .ifPresent(c -> c.onError(notification.getValue(),
                                    ObjectiveError.FLOWINSTALLATIONFAILED));
                }
            }).build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:DefaultSingleTablePipeline.java

示例2: activate

import com.google.common.cache.RemovalCause; //导入依赖的package包/类
@Activate
public void activate() {
    providerService = providerRegistry.register(this);

    pendingOperations = CacheBuilder.newBuilder()
            .expireAfterWrite(TIMEOUT, TimeUnit.SECONDS)
            .removalListener((RemovalNotification<Long, MeterOperation> notification) -> {
                if (notification.getCause() == RemovalCause.EXPIRED) {
                    providerService.meterOperationFailed(notification.getValue(),
                                                         MeterFailReason.TIMEOUT);
                }
            }).build();

    controller.addEventListener(listener);
    controller.addListener(listener);

    controller.getSwitches().forEach((sw -> createStatsCollection(sw)));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:OpenFlowMeterProvider.java

示例3: testCacheExpire

import com.google.common.cache.RemovalCause; //导入依赖的package包/类
@Test
public void testCacheExpire() throws InterruptedException {
    int total = 10;
    final Map<String, String> expired = new HashMap<>();
    RemovalListener removalListener = new RemovalListener<String, String>() {
        @Override
        public void onRemoval(RemovalNotification<String, String> notification) {
            if(RemovalCause.EXPIRED == notification.getCause()) {
                expired.put(notification.getKey(), notification.getValue());
            }
        }
    };
    Cache<String, String> myCache = CacheBuilder.newBuilder()
            .expireAfterWrite(2, TimeUnit.MILLISECONDS)
            .removalListener(removalListener)
            .build();
    for(int i = 0; i < total; i++) {
        myCache.put("key_" + i, "val_" + i);
    }
    Thread.sleep(10);
    myCache.cleanUp();
    assertEquals(total, expired.size());
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:24,代码来源:TransactionManagerTest.java

示例4: AutoScaleProcessor

import com.google.common.cache.RemovalCause; //导入依赖的package包/类
AutoScaleProcessor(AutoScalerConfig configuration,
                   ScheduledExecutorService maintenanceExecutor) {
    this.configuration = configuration;
    this.maintenanceExecutor = maintenanceExecutor;

    serializer = new JavaSerializer<>();
    writerConfig = EventWriterConfig.builder().build();
    writer = new AtomicReference<>();

    cache = CacheBuilder.newBuilder()
            .initialCapacity(INITIAL_CAPACITY)
            .maximumSize(MAX_CACHE_SIZE)
            .expireAfterAccess(configuration.getCacheExpiry().getSeconds(), TimeUnit.SECONDS)
            .removalListener(RemovalListeners.asynchronous((RemovalListener<String, Pair<Long, Long>>) notification -> {
                if (notification.getCause().equals(RemovalCause.EXPIRED)) {
                    triggerScaleDown(notification.getKey(), true);
                }
            }, maintenanceExecutor))
            .build();

    CompletableFuture.runAsync(this::bootstrapRequestWriters, maintenanceExecutor);
}
 
开发者ID:pravega,项目名称:pravega,代码行数:23,代码来源:AutoScaleProcessor.java

示例5: ShardWriterCache

import com.google.common.cache.RemovalCause; //导入依赖的package包/类
ShardWriterCache() {
  this.cache = CacheBuilder
      .newBuilder()
      .expireAfterWrite(IDLE_TIMEOUT_MS, TimeUnit.MILLISECONDS)
      .removalListener(new RemovalListener<Integer, ShardWriter<K, V>>() {
        @Override
        public void onRemoval(RemovalNotification<Integer, ShardWriter<K, V>> notification) {
          if (notification.getCause() != RemovalCause.EXPLICIT) {
            ShardWriter writer = notification.getValue();
            LOG.info("{} : Closing idle shard writer {} after 1 minute of idle time.",
                     writer.shard, writer.producerName);
            writer.producer.close();
          }
        }
      }).build();

  // run cache.cleanUp() every 10 seconds.
  SCHEDULED_CLEAN_UP_THREAD.scheduleAtFixedRate(
      new Runnable() {
        @Override
        public void run() {
          cache.cleanUp();
        }
      },
      CLEAN_UP_CHECK_INTERVAL_MS, CLEAN_UP_CHECK_INTERVAL_MS, TimeUnit.MILLISECONDS);
}
 
开发者ID:apache,项目名称:beam,代码行数:27,代码来源:KafkaIO.java

示例6: activate

import com.google.common.cache.RemovalCause; //导入依赖的package包/类
@Activate
public void activate() {
    providerService = providerRegistry.register(this);
    controller.addListener(listener);
    controller.addEventListener(listener);

    pendingBatches = CacheBuilder.newBuilder()
            .expireAfterWrite(10, TimeUnit.SECONDS)
            .removalListener((RemovalNotification<Long, InternalCacheEntry> notification) -> {
                if (notification.getCause() == RemovalCause.EXPIRED) {
                    providerService.batchOperationCompleted(notification.getKey(),
                                                            notification.getValue().failedCompletion());
                }
            }).build();


    for (OpenFlowSwitch sw : controller.getSwitches()) {
        FlowStatsCollector fsc = new FlowStatsCollector(sw, POLL_INTERVAL);
        fsc.start();
        collectors.put(new Dpid(sw.getId()), fsc);
    }


    log.info("Started");
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:26,代码来源:OpenFlowRuleProvider.java

示例7: onRemoval

import com.google.common.cache.RemovalCause; //导入依赖的package包/类
@Override
public void onRemoval(RemovalNotification<CacheValue, NodeDocument> n) {
    //If removed explicitly then we clear from L2
    if (n.getCause() == RemovalCause.EXPLICIT
            || n.getCause() == RemovalCause.REPLACED) {
        offHeapCache.invalidate(n.getKey());
    }

    //If removed because of size then we move it to
    //L2
    if (n.getCause() == RemovalCause.SIZE) {
        NodeDocument doc = n.getValue();
        if (doc != NodeDocument.NULL) {
            offHeapCache.put(n.getKey(),
                    new NodeDocReference(n.getKey(), doc));
        }
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:19,代码来源:NodeDocOffHeapCache.java

示例8: onRemoval

import com.google.common.cache.RemovalCause; //导入依赖的package包/类
@Override
	public void onRemoval(RemovalNotification<Writable, T> note) {
//		System.err.println("S0 Cache: " + activeKey + " " + note.getKey() + " " + note.getCause() + " " + cache.size());
		if (!(note.wasEvicted() || note.getCause() == RemovalCause.EXPLICIT)) {
			return;
		}
		if (activeKey != null && activeKey.equals(note.getKey())) {
			return;
		}

		try {
//			System.err.println("  s0emit: " + note.getCause() + " " + note.getKey() + " " + note.getValue());
			// Emit the record.
			collector.emit(new FValues(note.getKey(), note.getValue()));
		} catch (Throwable e) {
			lastThrown = e;
		}
	}
 
开发者ID:JamesLampton,项目名称:piggybank-squeal,代码行数:19,代码来源:Stage0Executor.java

示例9: createRequestResponseMap

import com.google.common.cache.RemovalCause; //导入依赖的package包/类
/**
 * Creates a new request response map, which holds requests that are waiting for responses.
 *
 * @return  A new cache for waiting request responses.
 */
protected Cache<String, Class<? extends ResponseMessage>> createRequestResponseMap()
{
    return CacheBuilder
        .newBuilder()
        .expireAfterWrite(IGNORED_REQUEST_TIMEOUT_MINUTES, TimeUnit.MINUTES)
        .removalListener(new RemovalListener<String, Class<? extends ResponseMessage>>()
        {
            @Override
            public void onRemoval(RemovalNotification<String, Class<? extends ResponseMessage>> notification)
            {
                if (notification.getCause() == RemovalCause.EXPIRED)
                {
                    MessageMarshaller.this.onRequestExpired(
                        notification.getKey(),
                        notification.getValue());
                }
            }
        }).build();
}
 
开发者ID:GuyPaddock,项目名称:JStratum,代码行数:25,代码来源:MessageMarshaller.java

示例10: init

import com.google.common.cache.RemovalCause; //导入依赖的package包/类
@Override
public void init(DeviceId deviceId, PipelinerContext context) {
    this.serviceDirectory = context.directory();
    this.deviceId = deviceId;

    flowRuleService = serviceDirectory.get(FlowRuleService.class);

    pendingNext = CacheBuilder.newBuilder()
            .expireAfterWrite(20, TimeUnit.SECONDS)
            .removalListener((RemovalNotification<Integer, NextObjective> notification) -> {
                if (notification.getCause() == RemovalCause.EXPIRED) {
                    notification.getValue().context()
                            .ifPresent(c -> c.onError(notification.getValue(),
                                    ObjectiveError.FLOWINSTALLATIONFAILED));
                }
            }).build();

    log.debug("Loaded handler behaviour EA1000Pipeliner for " + handler().data().deviceId().uri());
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:20,代码来源:EA1000Pipeliner.java

示例11: onRemoval

import com.google.common.cache.RemovalCause; //导入依赖的package包/类
@Override
public void onRemoval(RemovalNotification<String, CachedOffer> notification) {
  if (notification.getCause() == RemovalCause.EXPLICIT) {
    return;
  }

  LOG.debug("Cache removal for {} due to {}", notification.getKey(), notification.getCause());

  synchronized (offerCache) {
    if (notification.getValue().offerState == OfferState.AVAILABLE) {
      declineOffer(notification.getValue());
    } else {
      notification.getValue().expire();
    }
  }
}
 
开发者ID:HubSpot,项目名称:Singularity,代码行数:17,代码来源:SingularityOfferCache.java

示例12: onRemoval

import com.google.common.cache.RemovalCause; //导入依赖的package包/类
@Override
public void onRemoval(RemovalNotification<Object, Object> notification) {
    if (notification.getCause() == RemovalCause.SIZE) {
        if (evictionCounter % logInterval == 0) {
            logger.log(LogLevel.INFO, "Cache entries evicted. In-memory cache of {}: Size{{}} MaxSize{{}}, {} {}", cacheId, cache.size(), maxSize, cache.stats(), EVICTION_MITIGATION_MESSAGE);
        }
        evictionCounter++;
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:LoggingEvictionListener.java

示例13: onRemoval

import com.google.common.cache.RemovalCause; //导入依赖的package包/类
@Override
public void onRemoval(RemovalNotification<FileInfo, MuxedFile> notification) {
	if (notification.getCause() != RemovalCause.EXPLICIT) {
		MuxedFile muxedFile = notification.getValue();
		// This is racy, at worst we will re-trigger muxing for unlucky files being re-opened
		if (!openMuxFiles.containsValue(muxedFile)) {
			muxFiles.remove(muxedFile.getInfo(), muxedFile.getMuxer());
			logger.info("Expired {}: {} deleted = {}", notification.getCause(), muxedFile, safeDelete(muxedFile));
		} else {
			logger.warn("BUG: Expired {}: {}, but is still open!", notification.getCause(), muxedFile);
		}
	}
}
 
开发者ID:tfiskgul,项目名称:mux2fs,代码行数:14,代码来源:MuxFs.java

示例14: init

import com.google.common.cache.RemovalCause; //导入依赖的package包/类
public static void init() {
	RemovalListener<String, Object> removalListener = removal -> {
		if (removal.getCause() == RemovalCause.EXPIRED) {
			getModpacks();
		}
	};
	MODPACKS_CACHE = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).removalListener(removalListener).build();
	getModpacks();
	getMods();
}
 
开发者ID:HearthProject,项目名称:OneClient,代码行数:11,代码来源:Curse.java

示例15: init

import com.google.common.cache.RemovalCause; //导入依赖的package包/类
@Override
public void init(DeviceId deviceId, PipelinerContext context) {
    this.serviceDirectory = context.directory();
    this.deviceId = deviceId;

    pendingGroups = CacheBuilder.newBuilder()
            .expireAfterWrite(20, TimeUnit.SECONDS)
            .removalListener((RemovalNotification<GroupKey, NextObjective> notification) -> {
                if (notification.getCause() == RemovalCause.EXPIRED) {
                    fail(notification.getValue(), ObjectiveError.GROUPINSTALLATIONFAILED);
                }
            }).build();

    groupChecker.scheduleAtFixedRate(new GroupChecker(), 0, 500, TimeUnit.MILLISECONDS);

    coreService = serviceDirectory.get(CoreService.class);
    flowRuleService = serviceDirectory.get(FlowRuleService.class);
    groupService = serviceDirectory.get(GroupService.class);
    flowObjectiveStore = context.store();

    groupService.addListener(new InnerGroupListener());

    appId = coreService.registerApplication(
            "org.onosproject.driver.CentecV350Pipeline");

    initializePipeline();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:CentecV350Pipeline.java


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