use of io.confluent.ksql.util.KsqlHostInfo in project ksql by confluentinc.
the class KsLocatorTest method shouldReturnRemoteOwnerForDifferentHost.
@Test
public void shouldReturnRemoteOwnerForDifferentHost() {
// Given:
final HostInfo localHostInfo = new HostInfo("different", LOCAL_HOST_URL.getPort());
final KsqlHostInfo localHost = locator.asKsqlHost(localHostInfo);
getActiveAndStandbyMetadata(localHostInfo);
when(activeFilter.filter(eq(localHost))).thenReturn(Host.include(localHost));
when(livenessFilter.filter(eq(localHost))).thenReturn(Host.include(localHost));
// When:
final List<KsqlPartitionLocation> result = locator.locate(ImmutableList.of(KEY), routingOptions, routingFilterFactoryActive, false);
// Then:
List<KsqlNode> nodeList = result.get(0).getNodes();
assertThat(nodeList.stream().findFirst().map(KsqlNode::isLocal), is(Optional.of(false)));
}
use of io.confluent.ksql.util.KsqlHostInfo in project ksql by confluentinc.
the class KsLocatorTest method shouldReturnRemoteOwnerForDifferentPortOnLocalHost.
@Test
public void shouldReturnRemoteOwnerForDifferentPortOnLocalHost() {
// Given:
final HostInfo localHostInfo = new HostInfo("LOCALhost", LOCAL_HOST_URL.getPort() + 1);
final KsqlHostInfo localHost = locator.asKsqlHost(localHostInfo);
getActiveAndStandbyMetadata(localHostInfo);
when(activeFilter.filter(eq(localHost))).thenReturn(Host.include(localHost));
when(livenessFilter.filter(eq(localHost))).thenReturn(Host.include(localHost));
// When:
final List<KsqlPartitionLocation> result = locator.locate(ImmutableList.of(KEY), routingOptions, routingFilterFactoryActive, false);
// Then:
List<KsqlNode> nodeList = result.get(0).getNodes();
assertThat(nodeList.stream().findFirst().map(KsqlNode::isLocal), is(Optional.of(false)));
}
use of io.confluent.ksql.util.KsqlHostInfo in project ksql by confluentinc.
the class TestExecutorUtil method execute.
/**
* @param srClient if supplied, then schemas can be inferred from the schema registry.
* @return a list of persistent queries that should be run by the test executor, if a query was
* replaced via a CREATE OR REPLACE statement it will only appear once in the output list
*/
@SuppressWarnings("OptionalGetWithoutIsPresent")
private static List<PersistentQueryAndSources> execute(final KsqlEngine engine, final TestCase testCase, final KsqlConfig ksqlConfig, final ServiceContext serviceContext, final Optional<SchemaRegistryClient> srClient, final StubKafkaService stubKafkaService, final TestExecutionListener listener) {
final Map<QueryId, PersistentQueryAndSources> queries = new LinkedHashMap<>();
int idx = 0;
final Iterator<PlannedStatement> plans = planTestCase(engine, testCase, ksqlConfig, serviceContext, srClient, stubKafkaService);
try {
while (plans.hasNext()) {
++idx;
final PlannedStatement planned = plans.next();
if (planned.insertValues.isPresent()) {
final ConfiguredStatement<InsertValues> insertValues = planned.insertValues.get();
final SessionProperties sessionProperties = new SessionProperties(insertValues.getSessionConfig().getOverrides(), new KsqlHostInfo("host", 50), buildUrl(), false);
StubInsertValuesExecutor.of(stubKafkaService).execute(insertValues, sessionProperties, engine, engine.getServiceContext());
continue;
}
final ConfiguredKsqlPlan plan = planned.plan.orElseThrow(IllegalStateException::new);
listener.acceptPlan(plan);
final ExecuteResultAndSources result = executePlan(engine, plan);
if (!result.getSources().isPresent()) {
continue;
}
final PersistentQueryMetadata query = (PersistentQueryMetadata) result.getExecuteResult().getQuery().get();
listener.acceptQuery(query);
queries.put(query.getQueryId(), new PersistentQueryAndSources(query, result.getSources().get()));
}
return ImmutableList.copyOf(queries.values());
} catch (final KsqlStatementException e) {
if (testCase.expectedException().isPresent() && plans.hasNext()) {
throw new AssertionError("Only the last statement in a negative test should fail. " + "Yet in this case statement " + idx + " failed.", e);
}
throw e;
}
}
use of io.confluent.ksql.util.KsqlHostInfo in project ksql by confluentinc.
the class LivenessFilterTest method setUp.
@Before
public void setUp() {
activeHost = new KsqlHostInfo("activeHost", 2345);
standByHost1 = new KsqlHostInfo("standby1", 1234);
standByHost2 = new KsqlHostInfo("standby2", 5678);
Optional<HeartbeatAgent> optionalHeartbeatAgent = Optional.of(heartbeatAgent);
livenessFilter = new LivenessFilter(optionalHeartbeatAgent);
}
use of io.confluent.ksql.util.KsqlHostInfo in project ksql by confluentinc.
the class HeartbeatAgentTest method setUp.
@Before
public void setUp() {
localHostInfo = new HostInfo("localhost", 8088);
remoteHostInfo = new HostInfo("localhost", 8089);
localHost = new KsqlHostInfo("localhost", 8088);
remoteHost = new KsqlHostInfo("localhost", 8089);
Builder builder = HeartbeatAgent.builder();
heartbeatAgent = builder.heartbeatSendInterval(1).heartbeatMissedThreshold(2).addHostStatusListener(hostStatusListener).build(ksqlEngine, serviceContext);
heartbeatAgent.setLocalAddress(LOCALHOST_URL);
hostsStatus = ImmutableMap.of(localHost, new HostStatus(true, 0L), remoteHost, new HostStatus(true, 0L));
allMetadata0 = ImmutableList.of(streamsMetadata0);
allMetadata1 = ImmutableList.of(streamsMetadata1);
}
Aggregations