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


Java StreamManager.create方法代码示例

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


在下文中一共展示了StreamManager.create方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
 
开发者ID:pravega,项目名称:flink-connectors,代码行数:26,代码来源:SetupUtils.java

示例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);
    }
}
 
开发者ID:pravega,项目名称:pravega-samples,代码行数:20,代码来源:HelloWorldWriter.java

示例3: 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);
}
 
开发者ID:pravega,项目名称:pravega,代码行数:29,代码来源:InProcPravegaClusterTest.java

示例4: 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);
}
 
开发者ID:pravega,项目名称:pravega,代码行数:26,代码来源:SetupUtils.java

示例5: 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);
}
 
开发者ID:pravega,项目名称:flink-connectors,代码行数:8,代码来源:FlinkPravegaParams.java

示例6: 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);
    }
}
 
开发者ID:pravega,项目名称:pravega-samples,代码行数:38,代码来源:HelloWorldReader.java

示例7: 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);
}
 
开发者ID:pravega,项目名称:pravega-samples,代码行数:9,代码来源:SharedConfigCli.java

示例8: 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);
    }
}
 
开发者ID:pravega,项目名称:pravega-samples,代码行数:38,代码来源:ConsoleReader.java

示例9: 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));
}
 
开发者ID:pravega,项目名称:pravega,代码行数:8,代码来源:ReaderCheckpointTest.java

示例10: runTest

import io.pravega.client.admin.StreamManager; //导入方法依赖的package包/类
private void runTest(final Set<String> streamNames, final int numParallelReaders, final int numSegments)
        throws Exception {
    @Cleanup
    StreamManager streamManager = StreamManager.create(SETUP_UTILS.getControllerUri());
    streamManager.createScope(SETUP_UTILS.getScope());
    streamNames.stream().forEach(stream -> {
        streamManager.createStream(SETUP_UTILS.getScope(),
                                   stream,
                                   StreamConfiguration.builder()
                                           .scope(SETUP_UTILS.getScope())
                                           .streamName(stream)
                                           .scalingPolicy(ScalingPolicy.fixed(numSegments))
                                           .build());
        log.info("Created stream: {}", stream);
    });

    @Cleanup
    ClientFactory clientFactory = ClientFactory.withScope(SETUP_UTILS.getScope(), SETUP_UTILS.getControllerUri());
    streamNames.stream().forEach(stream -> {
        EventStreamWriter<Integer> eventWriter = clientFactory.createEventWriter(
                stream, new IntegerSerializer(), EventWriterConfig.builder().build());
        for (Integer i = 0; i < NUM_TEST_EVENTS; i++) {
            eventWriter.writeEvent(String.valueOf(i), i);
        }
        eventWriter.flush();
        log.info("Wrote {} events", NUM_TEST_EVENTS);
    });

    final String readerGroupName = "testreadergroup" + RandomStringUtils.randomAlphanumeric(10).toLowerCase();

    @Cleanup
    ReaderGroupManager readerGroupManager = ReaderGroupManager.withScope(SETUP_UTILS.getScope(),
                                                                         SETUP_UTILS.getControllerUri());
    readerGroupManager.createReaderGroup(readerGroupName,
                                         ReaderGroupConfig.builder().startingTime(0).build(),
                                         streamNames);

    Collection<Integer> read = readAllEvents(numParallelReaders, clientFactory, readerGroupName, numSegments);

    Assert.assertEquals(NUM_TEST_EVENTS * streamNames.size(), read.size());
    // Check unique events.
    Assert.assertEquals(NUM_TEST_EVENTS, new TreeSet<>(read).size());
    readerGroupManager.deleteReaderGroup(readerGroupName);
}
 
开发者ID:pravega,项目名称:pravega,代码行数:45,代码来源:MultiReadersEndToEndTest.java

示例11: testReadWrite

import io.pravega.client.admin.StreamManager; //导入方法依赖的package包/类
private void testReadWrite() {
    List<URI> ctlURIs = this.controllerInstance.getServiceDetails();
    URI controllerUri = ctlURIs.get(0);

    String scope = "testscope" + RandomStringUtils.randomAlphanumeric(10);
    String stream = "teststream" + RandomStringUtils.randomAlphanumeric(10);

    @Cleanup
    StreamManager streamManager = StreamManager.create(controllerUri);
    Assert.assertTrue(streamManager.createScope(scope));

    // Create stream with large number of segments so that most segment containers are used.
    Assert.assertTrue(streamManager.createStream(scope, stream, StreamConfiguration.builder()
            .scope(scope)
            .streamName(stream)
            .scalingPolicy(ScalingPolicy.fixed(10))
            .build()));

    @Cleanup
    ClientFactory clientFactory = ClientFactory.withScope(scope, controllerUri);

    log.info("Invoking writer with controller URI: {}", controllerUri);
    @Cleanup
    EventStreamWriter<Serializable> writer = clientFactory.createEventWriter(stream,
            new JavaSerializer<>(),
            EventWriterConfig.builder().build());

    final int numEvents = 1000;
    final String fixedEvent = "testevent";
    for (int i = 0; i < numEvents; i++) {
        log.debug("Producing event: {} ", fixedEvent);
        writer.writeEvent(String.valueOf(i), fixedEvent);
    }
    writer.flush();

    log.info("Invoking reader with controller URI: {}", controllerUri);
    final String readerGroup = "testreadergroup" + RandomStringUtils.randomAlphanumeric(10);
    ReaderGroupManager groupManager = ReaderGroupManager.withScope(scope, controllerUri);
    groupManager.createReaderGroup(readerGroup,
            ReaderGroupConfig.builder().disableAutomaticCheckpoints().startingTime(0).build(),
            Collections.singleton(stream));

    @Cleanup
    EventStreamReader<String> reader = clientFactory.createReader(UUID.randomUUID().toString(),
            readerGroup,
            new JavaSerializer<>(),
            ReaderConfig.builder().build());
    for (int i = 0; i < numEvents; i++) {
        try {
            String event = reader.readNextEvent(60000).getEvent();
            Assert.assertEquals(fixedEvent, event);
        } catch (ReinitializationRequiredException e) {
            log.error("Unexpected request to reinitialize {}", e);
            throw new IllegalStateException("Unexpected request to reinitialize");
        }
    }
}
 
开发者ID:pravega,项目名称:pravega,代码行数:58,代码来源:MultiSegmentStoreTest.java

示例12: testSessionExpiryTolerance

import io.pravega.client.admin.StreamManager; //导入方法依赖的package包/类
private void testSessionExpiryTolerance(final ControllerWrapper controllerWrapper, final int controllerPort) throws Exception {

        controllerWrapper.awaitRunning();

        // Simulate ZK session timeout
        controllerWrapper.forceClientSessionExpiry();

        // Now, that session has expired, lets do some operations.
        controllerWrapper.awaitPaused();

        controllerWrapper.awaitRunning();

        URI controllerURI = URI.create("tcp://localhost:" + controllerPort);
        StreamManager streamManager = StreamManager.create(controllerURI);

        // Create scope
        streamManager.createScope(SCOPE);

        // Create stream
        StreamConfiguration streamConfiguration = StreamConfiguration.builder()
                .scope(SCOPE)
                .streamName(STREAM)
                .scalingPolicy(ScalingPolicy.fixed(1))
                .build();
        streamManager.createStream(SCOPE, STREAM, streamConfiguration);

        streamManager.sealStream(SCOPE, STREAM);

        streamManager.deleteStream(SCOPE, STREAM);

        streamManager.deleteScope(SCOPE);

        controllerWrapper.close();

        controllerWrapper.awaitTerminated();
    }
 
开发者ID:pravega,项目名称:pravega,代码行数:37,代码来源:ControllerFailoverTest.java


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