本文整理汇总了Java中io.pravega.client.admin.StreamManager类的典型用法代码示例。如果您正苦于以下问题:Java StreamManager类的具体用法?Java StreamManager怎么用?Java StreamManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StreamManager类属于io.pravega.client.admin包,在下文中一共展示了StreamManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTestStream
import io.pravega.client.admin.StreamManager; //导入依赖的package包/类
/**
* Create the test stream.
*
* @param streamName Name of the test stream.
* @param numSegments Number of segments to be created for this stream.
*
* @throws Exception on any errors.
*/
public void createTestStream(final String streamName, final int numSegments)
throws Exception {
Preconditions.checkState(this.started.get(), "Services not yet started");
Preconditions.checkNotNull(streamName);
Preconditions.checkArgument(numSegments > 0);
@Cleanup
StreamManager streamManager = StreamManager.create(getControllerUri());
streamManager.createScope(this.scope);
streamManager.createStream(this.scope, streamName,
StreamConfiguration.builder()
.scope(this.scope)
.streamName(streamName)
.scalingPolicy(ScalingPolicy.fixed(numSegments))
.build());
log.info("Created stream: " + streamName);
}
示例2: run
import io.pravega.client.admin.StreamManager; //导入依赖的package包/类
public void run(String routingKey, String message) {
StreamManager streamManager = StreamManager.create(controllerURI);
final boolean scopeIsNew = streamManager.createScope(scope);
StreamConfiguration streamConfig = StreamConfiguration.builder()
.scalingPolicy(ScalingPolicy.fixed(1))
.build();
final boolean streamIsNew = streamManager.createStream(scope, streamName, streamConfig);
try (ClientFactory clientFactory = ClientFactory.withScope(scope, controllerURI);
EventStreamWriter<String> writer = clientFactory.createEventWriter(streamName,
new JavaSerializer<String>(),
EventWriterConfig.builder().build())) {
System.out.format("Writing message: '%s' with routing-key: '%s' to stream '%s / %s'%n",
message, routingKey, scope, streamName);
final CompletableFuture writeFuture = writer.writeEvent(routingKey, message);
}
}
示例3: SharedMap
import io.pravega.client.admin.StreamManager; //导入依赖的package包/类
/**
* Creates the shared state using a synchronizer based on the given stream name.
*
* @param clientFactory - the Pravega ClientFactory to use to create the StateSynchronizer.
* @param streamManager - the Pravega StreamManager to use to create the Scope and the Stream used by the StateSynchronizer
* @param scope - the Scope to use to create the Stream used by the StateSynchronizer.
* @param name - the name of the Stream to be used by the StateSynchronizer.
*/
public SharedMap(ClientFactory clientFactory, StreamManager streamManager, String scope, String name){
streamManager.createScope(scope);
StreamConfiguration streamConfig = StreamConfiguration.builder()
.scalingPolicy(ScalingPolicy.fixed(1))
.build();
streamManager.createStream(scope, name, streamConfig);
this.stateSynchronizer = clientFactory.createStateSynchronizer(name,
new JavaSerializer<StateUpdate<K,V>>(),
new JavaSerializer<CreateState<K,V>>(),
SynchronizerConfig.builder().build());
stateSynchronizer.initialize(new CreateState<K,V>(new ConcurrentHashMap<K,V>()));
}
示例4: createTestStream
import io.pravega.client.admin.StreamManager; //导入依赖的package包/类
/**
* Create the test stream.
*
* @throws Exception on any errors.
*/
@Test
public void createTestStream()
throws Exception {
Assert.assertNotNull("Pravega not initialized", localPravega);
String scope = "Scope";
String streamName = "Stream";
int numSegments = 10;
@Cleanup
StreamManager streamManager = StreamManager.create(URI.create(
localPravega.getInProcPravegaCluster().getControllerURI()
));
streamManager.createScope(scope);
Assert.assertTrue("Stream creation is not successful ",
streamManager.createStream(scope, streamName, StreamConfiguration.builder()
.scope(scope)
.streamName(streamName)
.scalingPolicy(ScalingPolicy.fixed(numSegments))
.build()));
log.info("Created stream: " + streamName);
}
示例5: createTestStream
import io.pravega.client.admin.StreamManager; //导入依赖的package包/类
/**
* Create the test stream.
*
* @param streamName Name of the test stream.
* @param numSegments Number of segments to be created for this stream.
*
* @throws Exception on any errors.
*/
public void createTestStream(final String streamName, final int numSegments)
throws Exception {
Preconditions.checkState(this.started.get(), "Services not yet started");
Preconditions.checkNotNull(streamName);
Preconditions.checkArgument(numSegments > 0);
@Cleanup
StreamManager streamManager = StreamManager.create(this.controllerUri);
streamManager.createScope(this.scope);
streamManager.createStream(this.scope, streamName,
StreamConfiguration.builder()
.scope(this.scope)
.streamName(streamName)
.scalingPolicy(ScalingPolicy.fixed(numSegments))
.build());
log.info("Created stream: " + streamName);
}
示例6: streamManagerImpltest
import io.pravega.client.admin.StreamManager; //导入依赖的package包/类
@Test(timeout = 10000)
public void streamManagerImpltest() {
@Cleanup
StreamManager streamManager = new StreamManagerImpl(controller);
// Create and delete scope
assertTrue(streamManager.createScope(SCOPE));
assertTrue(streamManager.deleteScope(SCOPE));
// Create scope twice
assertTrue(streamManager.createScope(SCOPE));
assertFalse(streamManager.createScope(SCOPE));
assertTrue(streamManager.deleteScope(SCOPE));
// Delete twice
assertFalse(streamManager.deleteScope(SCOPE));
}
示例7: createStream
import io.pravega.client.admin.StreamManager; //导入依赖的package包/类
public void createStream(final StreamId streamId, final ScalingPolicy scalingPolicy) {
StreamManager streamManager = StreamManager.create(getControllerUri());
streamManager.createScope(streamId.getScope());
StreamConfiguration streamConfig = StreamConfiguration.builder().scalingPolicy(scalingPolicy).build();
streamManager.createStream(streamId.getScope(), streamId.getName(), streamConfig);
}
示例8: run
import io.pravega.client.admin.StreamManager; //导入依赖的package包/类
public void run() {
StreamManager streamManager = StreamManager.create(controllerURI);
final boolean scopeIsNew = streamManager.createScope(scope);
StreamConfiguration streamConfig = StreamConfiguration.builder()
.scalingPolicy(ScalingPolicy.fixed(1))
.build();
final boolean streamIsNew = streamManager.createStream(scope, streamName, streamConfig);
final String readerGroup = UUID.randomUUID().toString().replace("-", "");
final ReaderGroupConfig readerGroupConfig = ReaderGroupConfig.builder()
.build();
try (ReaderGroupManager readerGroupManager = ReaderGroupManager.withScope(scope, controllerURI)) {
readerGroupManager.createReaderGroup(readerGroup, readerGroupConfig, Collections.singleton(streamName));
}
try (ClientFactory clientFactory = ClientFactory.withScope(scope, controllerURI);
EventStreamReader<String> reader = clientFactory.createReader("reader",
readerGroup,
new JavaSerializer<String>(),
ReaderConfig.builder().build())) {
System.out.format("Reading all the events from %s/%s%n", scope, streamName);
EventRead<String> event = null;
do {
try {
event = reader.readNextEvent(READER_TIMEOUT_MS);
if (event.getEvent() != null) {
System.out.format("Read event '%s'%n", event.getEvent());
}
} catch (ReinitializationRequiredException e) {
//There are certain circumstances where the reader needs to be reinitialized
e.printStackTrace();
}
} while (event.getEvent() != null);
System.out.format("No more events from %s/%s%n", scope, streamName);
}
}
示例9: SharedConfigCli
import io.pravega.client.admin.StreamManager; //导入依赖的package包/类
public SharedConfigCli(String scope, String configName, URI controllerURI) {
this.configName = configName;
this.clientFactory = ClientFactory.withScope(scope, controllerURI);
this.streamManager = StreamManager.create(controllerURI);
this.config = new SharedConfig<>(clientFactory, streamManager, scope, configName);
}
示例10: run
import io.pravega.client.admin.StreamManager; //导入依赖的package包/类
public void run() {
final String readerGroup = UUID.randomUUID().toString().replace("-", "");
final ReaderGroupConfig readerGroupConfig = ReaderGroupConfig.builder().startingPosition(Sequence.MIN_VALUE)
.build();
StreamManager streamManager = StreamManager.create(controllerURI);
streamManager.createScope(scope);
StreamConfiguration streamConfig = StreamConfiguration.builder().scope(scope).streamName(streamName)
.scalingPolicy(ScalingPolicy.fixed(1))
.build();
streamManager.createStream(scope, streamName, streamConfig);
try (ReaderGroupManager readerGroupManager = ReaderGroupManager.withScope(scope, controllerURI)) {
readerGroupManager.createReaderGroup(readerGroup, readerGroupConfig, Collections.singleton(streamName));
}
try (ClientFactory clientFactory = ClientFactory.withScope(scope, controllerURI);
EventStreamReader<String> reader = clientFactory.createReader("reader",
readerGroup,
new JavaSerializer<String>(),
ReaderConfig.builder().build())) {
System.out.format("******** Reading events from %s/%s%n", scope, streamName);
EventRead<String> event = null;
do {
try {
event = reader.readNextEvent(READER_TIMEOUT_MS);
if(event != null) {
System.out.format("'%s'%n", event.getEvent());
}
} catch (ReinitializationRequiredException e) {
//There are certain circumstances where the reader needs to be reinitialized
e.printStackTrace();
}
}while(true);
}
}
示例11: createScopeAndStream
import io.pravega.client.admin.StreamManager; //导入依赖的package包/类
void createScopeAndStream(String scope, String stream, StreamConfiguration config, StreamManager streamManager) {
Boolean createScopeStatus = streamManager.createScope(scope);
log.info("Creating scope with scope name {}", scope);
log.debug("Create scope status {}", createScopeStatus);
Boolean createStreamStatus = streamManager.createStream(scope, stream, config);
log.debug("Create stream status {}", createStreamStatus);
}
示例12: setup
import io.pravega.client.admin.StreamManager; //导入依赖的package包/类
@Before
public void setup() throws URISyntaxException {
controllerURI = fetchControllerURI();
StreamManager streamManager = StreamManager.create(controllerURI);
assertTrue("Creating Scope", streamManager.createScope(SCOPE));
assertTrue("Creating stream", streamManager.createStream(SCOPE, STREAM, streamConfig));
}
示例13: SharedConfig
import io.pravega.client.admin.StreamManager; //导入依赖的package包/类
public SharedConfig(ClientFactory clientFactory, StreamManager streamManager, String scope, String name){
this.properties = new SharedMap<K, V>(clientFactory, streamManager, scope, name);
}
示例14: getStreamManager
import io.pravega.client.admin.StreamManager; //导入依赖的package包/类
@Override
protected StreamManager getStreamManager() {
return this.streamManager;
}
示例15: getStreamManager
import io.pravega.client.admin.StreamManager; //导入依赖的package包/类
@Override
protected StreamManager getStreamManager() {
return this.streamManager.get();
}