本文整理汇总了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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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()));
}
示例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);
}
示例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();
}
示例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());
}
示例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();
}
示例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);
}
示例15: DirectExecutorService
import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
DirectExecutorService() {
delegate = MoreExecutors.newDirectExecutorService();
}