use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.
the class SourcesImpl method getSourceAsync.
@Override
public CompletableFuture<SourceConfig> getSourceAsync(String tenant, String namespace, String sourceName) {
WebTarget path = source.path(tenant).path(namespace).path(sourceName);
final CompletableFuture<SourceConfig> future = new CompletableFuture<>();
asyncGetRequest(path, new InvocationCallback<Response>() {
@Override
public void completed(Response response) {
if (response.getStatus() != Response.Status.OK.getStatusCode()) {
future.completeExceptionally(getApiException(response));
} else {
future.complete(response.readEntity(SourceConfig.class));
}
}
@Override
public void failed(Throwable throwable) {
future.completeExceptionally(getApiException(throwable.getCause()));
}
});
return future;
}
use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.
the class TestCmdSources method testMissingArchive.
@Test(expectedExceptions = ParameterException.class, expectedExceptionsMessageRegExp = "Source archive not specified")
public void testMissingArchive() throws Exception {
SourceConfig sourceConfig = getSourceConfig();
sourceConfig.setArchive(null);
testCmdSourceCliMissingArgs(TENANT, NAMESPACE, NAME, TOPIC_NAME, SERDE_CLASS_NAME, PROCESSING_GUARANTEES, PARALLELISM, null, CPU, RAM, DISK, SINK_CONFIG_STRING, sourceConfig);
}
use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.
the class TestCmdSources method testCmdSourceConfigFileMissingConfig.
@Test
public void testCmdSourceConfigFileMissingConfig() throws Exception {
SourceConfig testSourceConfig = getSourceConfig();
testSourceConfig.setConfigs(null);
SourceConfig expectedSourceConfig = getSourceConfig();
expectedSourceConfig.setConfigs(null);
testCmdSourceConfigFile(testSourceConfig, expectedSourceConfig);
}
use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.
the class TestCmdSources method testMissingProcessingGuarantees.
@Test
public void testMissingProcessingGuarantees() throws Exception {
SourceConfig sourceConfig = getSourceConfig();
sourceConfig.setProcessingGuarantees(null);
testCmdSourceCliMissingArgs(TENANT, NAMESPACE, NAME, TOPIC_NAME, SERDE_CLASS_NAME, null, PARALLELISM, JAR_FILE_PATH, CPU, RAM, DISK, SINK_CONFIG_STRING, sourceConfig);
}
use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.
the class TestCmdSources method testCmdSourceConfigFile.
public void testCmdSourceConfigFile(SourceConfig testSourceConfig, SourceConfig expectedSourceConfig) throws Exception {
File file = Files.createTempFile("", "").toFile();
new YAMLMapper().writeValue(file, testSourceConfig);
Assert.assertEquals(testSourceConfig, CmdUtils.loadConfig(file.getAbsolutePath(), SourceConfig.class));
// test create source
createSource.sourceConfigFile = file.getAbsolutePath();
createSource.processArguments();
createSource.runCmd();
// test update source
updateSource.sourceConfigFile = file.getAbsolutePath();
updateSource.processArguments();
updateSource.runCmd();
// test local runner
localSourceRunner.sourceConfigFile = file.getAbsolutePath();
localSourceRunner.processArguments();
localSourceRunner.runCmd();
verify(createSource).validateSourceConfigs(eq(expectedSourceConfig));
verify(updateSource).validateSourceConfigs(eq(expectedSourceConfig));
verify(localSourceRunner).validateSourceConfigs(eq(expectedSourceConfig));
}
Aggregations