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


Java MoreExecutors.newDirectExecutorService方法代码示例

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


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

示例1: testMuxedFileSizeCacheIsEmptyBeforeMuxing

import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
@Test
public void testMuxedFileSizeCacheIsEmptyBeforeMuxing()
		throws Exception {
	// Given
	mux2fs = new MuxFs(mirrorRoot, tempDir, muxerFactory, sleeper, fileChannelCloser, MoreExecutors.newDirectExecutorService());
	fs = mux2fs;
	StatFiller stat = mock(StatFiller.class);
	Path mkv = mockPath("file.mkv", 700000000L);
	Path srt = mockPath("file.srt", 2000L);
	mockDirectoryStream(mirrorRoot, srt, mkv);
	when(stat.statWithSize(eq(mkv), sizeGetterCaptor.capture(), extraSizeGetterCaptor.capture())).thenReturn(mock(UnixFileStat.class));
	mockAttributes(mkv, 234);
	FileInfo info = FileInfo.of(mkv);
	// When
	int result = fs.getattr("file.mkv", stat);
	// Then
	assertThat(result).isEqualTo(SUCCESS);
	verify(stat).statWithSize(eq(mkv), any(), any());
	verifyNoMoreInteractions(stat);
	assertThat(sizeGetterCaptor.getValue().apply(info)).isEmpty();
	assertThat(extraSizeGetterCaptor.getValue().get()).isEqualTo(2000L);
}
 
开发者ID:tfiskgul,项目名称:mux2fs,代码行数:23,代码来源:MuxFsTest.java

示例2: startNewDomDataBroker

import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
public void startNewDomDataBroker() {
    checkState(this.executor != null, "Executor needs to be set");
    final InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER",
        MoreExecutors.newDirectExecutorService());
    final InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG",
        MoreExecutors.newDirectExecutorService());
    this.newDatastores = ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
            .put(LogicalDatastoreType.OPERATIONAL, operStore)
            .put(LogicalDatastoreType.CONFIGURATION, configStore)
            .build();

    this.newDOMDataBroker = new SerializedDOMDataBroker(this.newDatastores, this.executor);

    this.mockSchemaService.registerSchemaContextListener(configStore);
    this.mockSchemaService.registerSchemaContextListener(operStore);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:BindingTestContext.java

示例3: setUp

import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
@Setup(Level.Trial)
@Override
public void setUp() throws Exception {
    ListeningExecutorService dsExec = MoreExecutors.newDirectExecutorService();
    executor = MoreExecutors.listeningDecorator(
            MoreExecutors.getExitingExecutorService((ThreadPoolExecutor) Executors.newFixedThreadPool(1), 1L,
                    TimeUnit.SECONDS));

    InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", dsExec);
    InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", dsExec);
    Map<LogicalDatastoreType, DOMStore> datastores = ImmutableMap.of(
        LogicalDatastoreType.OPERATIONAL, (DOMStore)operStore,
        LogicalDatastoreType.CONFIGURATION, configStore);

    domBroker = new SerializedDOMDataBroker(datastores, executor);
    schemaContext = BenchmarkModel.createTestContext();
    configStore.onGlobalContextUpdated(schemaContext);
    operStore.onGlobalContextUpdated(schemaContext);
    initTestNode();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:InMemoryBrokerWriteTransactionBenchmark.java

示例4: setupStore

import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
@Before
public void setupStore() {

    InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER",
            MoreExecutors.newDirectExecutorService());
    InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG",
            MoreExecutors.newDirectExecutorService());
    schemaContext = TestModel.createTestContext();

    operStore.onGlobalContextUpdated(schemaContext);
    configStore.onGlobalContextUpdated(schemaContext);

    ImmutableMap<LogicalDatastoreType, DOMStore> stores = ImmutableMap.<LogicalDatastoreType, DOMStore> builder() //
            .put(CONFIGURATION, configStore) //
            .put(OPERATIONAL, operStore) //
            .build();

    commitExecutor = new CommitExecutorService(Executors.newSingleThreadExecutor());
    futureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(1, 5, "FCB");
    executor = new DeadlockDetectingListeningExecutorService(commitExecutor,
            TransactionCommitDeadlockException.DEADLOCK_EXCEPTION_SUPPLIER, futureExecutor);
    domBroker = new SerializedDOMDataBroker(stores, executor);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:DOMBrokerTest.java

示例5: setupStore

import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
@Before
public void setupStore() {
    InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService());
    InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService());
    schemaContext = TestModel.createTestContext();

    operStore.onGlobalContextUpdated(schemaContext);
    configStore.onGlobalContextUpdated(schemaContext);

    ImmutableMap<LogicalDatastoreType, DOMStore> stores = ImmutableMap.<LogicalDatastoreType, DOMStore> builder() //
            .put(CONFIGURATION, configStore) //
            .put(OPERATIONAL, operStore) //
            .build();
    ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
    domBroker = new SerializedDOMDataBroker(stores, executor);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:DOMBrokerPerformanceTest.java

示例6: setupStore

import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
@Before
public void setupStore() {
    InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService());
    InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService());
    schemaContext = TestModel.createTestContext();

    operStore.onGlobalContextUpdated(schemaContext);
    configStore.onGlobalContextUpdated(schemaContext);

    ImmutableMap<LogicalDatastoreType, DOMStore> stores = ImmutableMap.<LogicalDatastoreType, DOMStore> builder() //
            .put(CONFIGURATION, configStore) //
            .put(OPERATIONAL, operStore) //
            .build();

    ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
    domBroker = new SerializedDOMDataBroker(stores, executor);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:DOMTransactionChainTest.java

示例7: testMuxedFileSizeIsCachedAfterMuxing

import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
@Test
public void testMuxedFileSizeIsCachedAfterMuxing()
		throws Exception {
	// Given
	mux2fs = new MuxFs(mirrorRoot, tempDir, muxerFactory, sleeper, fileChannelCloser, MoreExecutors.newDirectExecutorService());
	fs = mux2fs;
	StatFiller stat = mock(StatFiller.class);
	Path mkv = mockPath("file.mkv", 700000000L);
	Path srt = mockPath("file.srt", 2000L);
	mockDirectoryStream(mirrorRoot, srt, mkv);
	when(stat.statWithSize(eq(mkv), sizeGetterCaptor.capture(), extraSizeGetterCaptor.capture())).thenReturn(mock(UnixFileStat.class));
	mockAttributes(mkv, 24365);
	FileHandleFiller filler = mock(FileHandleFiller.class);
	ArgumentCaptor<Integer> handleCaptor = ArgumentCaptor.forClass(Integer.class);
	doNothing().when(filler).setFileHandle(handleCaptor.capture());
	Muxer muxer = mock(Muxer.class);
	when(muxerFactory.from(mkv, srt, tempDir)).thenReturn(muxer);
	Path muxedFile = mockPath(tempDir, "file1-muxed.mkv", 700000000L + 2000L + 534L);
	when(muxer.getOutput()).thenReturn(Optional.of(muxedFile));
	when(fileSystem.provider().newFileChannel(eq(muxedFile), eq(set(StandardOpenOption.READ)))).thenReturn(mock(FileChannel.class));
	when(muxer.state()).thenReturn(State.SUCCESSFUL);
	int openResult = fs.open("file.mkv", filler);
	int closeResult = fs.release("file.mkv", handleCaptor.getValue());
	// When
	int result = fs.getattr("file.mkv", stat);
	// Then
	assertThat(result).isEqualTo(SUCCESS);
	assertThat(openResult).isEqualTo(SUCCESS);
	assertThat(closeResult).isEqualTo(SUCCESS);
	verify(stat).statWithSize(eq(mkv), any(), any());
	verifyNoMoreInteractions(stat);
	Optional<Long> sizeGetter = sizeGetterCaptor.getValue().apply(FileInfo.of(mkv));
	assertThat(sizeGetter).isNotEmpty();
	assertThat(sizeGetter).hasValue(700000000L + 2000L + 534L);
	assertThat(extraSizeGetterCaptor.getValue().get()).isEqualTo(2000L);
}
 
开发者ID:tfiskgul,项目名称:mux2fs,代码行数:37,代码来源:MuxFsTest.java

示例8: setUp

import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
@Before
public void setUp() {
    deviceBlacklist = new HashSet<>();
    portBlacklist = new HashSet<>();
    cfg = new TestSuppressionConfig();
    coreService = createMock(CoreService.class);
    expect(coreService.registerApplication(appId.name()))
            .andReturn(appId).anyTimes();
    replay(coreService);

    provider.cfgService = new ComponentConfigAdapter();
    provider.coreService = coreService;
    provider.cfgRegistry = configRegistry;

    provider.deviceService = deviceService;
    provider.linkService = linkService;
    provider.packetService = packetService;
    provider.providerRegistry = linkRegistry;
    provider.masterService = masterService;
    provider.clusterMetadataService = new ClusterMetadataServiceAdapter();

    provider.activate(null);

    provider.eventExecutor = MoreExecutors.newDirectExecutorService();

    providerService = linkRegistry.registeredProvider();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:LldpLinkProviderTest.java

示例9: setUp

import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
@Before
public void setUp() {
    mgr = new FlowRuleManager();
    mgr.store = new SimpleFlowRuleStore();
    injectEventDispatcher(mgr, new TestEventDispatcher());
    mgr.deviceService = new TestDeviceService();
    mgr.mastershipService = new TestMastershipService();
    mgr.coreService = new TestCoreService();
    mgr.operationsService = MoreExecutors.newDirectExecutorService();
    mgr.deviceInstallers = MoreExecutors.newDirectExecutorService();
    mgr.cfgService = new ComponentConfigAdapter();
    service = mgr;
    registry = mgr;

    driverService = new TestDriverManager();
    driverService.addDriver(new DefaultDriver("foo", ImmutableList.of(), "", "", "",
                                              ImmutableMap.of(FlowRuleProgrammable.class,
                                                              TestFlowRuleProgrammable.class),
                                              ImmutableMap.of()));

    mgr.activate(null);
    mgr.addListener(listener);
    provider = new TestProvider(PID);
    providerService = registry.register(provider);
    appId = new TestApplicationId(0, "FlowRuleManagerTest");
    assertTrue("provider should be registered",
               registry.getProviders().contains(provider.id()));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:FlowRuleManagerTest.java

示例10: setUp

import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
  PDFSConfig config = new PDFSConfig(
      MoreExecutors.newDirectExecutorService(),
      null,
      null,
      ENDPOINTS_PROVIDER,
      LOCAL_ENDPOINT,
      true);
  hadoopConf = new Configuration();
  fs = newPseudoDistributedFileSystem(config);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:13,代码来源:TestPseudoDistributedFileSystem.java

示例11: setUp

import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
@Before
public void setUp() {
    ListeningExecutorService executor = MoreExecutors.newDirectExecutorService();
    BindingBrokerTestFactory factory = new BindingBrokerTestFactory();
    factory.setExecutor(executor);
    factory.setStartWithParsedSchema(getStartWithSchema());
    testContext = factory.getTestContext();
    testContext.start();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:AbstractDataServiceTest.java

示例12: setUp

import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    doReturn(new CommitStatus(Collections.<ObjectName>emptyList(), Collections.<ObjectName>emptyList(),
            Collections.<ObjectName>emptyList())).when(blankTx).hit();
    tracker = new BlankTransactionServiceTracker(blankTx, 10, MoreExecutors.newDirectExecutorService());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:8,代码来源:BlankTransactionServiceTrackerTest.java

示例13: testConflictingException

import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
@Test
public void testConflictingException() throws Exception {
    int maxAttempts = 2;
    tracker = new BlankTransactionServiceTracker(blankTx, maxAttempts, MoreExecutors.newDirectExecutorService());

    final ConflictingVersionException ex = new ConflictingVersionException();
    doThrow(ex).when(blankTx).hit();

    tracker.addingService(getMockServiceReference());
    verify(blankTx, times(maxAttempts)).hit();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:12,代码来源:BlankTransactionServiceTrackerTest.java

示例14: setup

import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
@Before
public void setup() {
    doReturn("tx").when(transaction).getIdentifier();

    DOMStore store = new InMemoryDOMDataStore("OPER",
        MoreExecutors.newDirectExecutorService());

    coordinator = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, store),
            futureExecutor);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:11,代码来源:ConcurrentDOMDataBrokerTest.java

示例15: DirectExecutorService

import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
DirectExecutorService() {
  delegate = MoreExecutors.newDirectExecutorService();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:MockGlideExecutor.java


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