use of org.apache.pulsar.common.policies.data.BrokerNamespaceIsolationDataImpl in project pulsar by apache.
the class ClustersImpl method getBrokersWithNamespaceIsolationPolicyAsync.
@Override
public CompletableFuture<List<BrokerNamespaceIsolationData>> getBrokersWithNamespaceIsolationPolicyAsync(String cluster) {
WebTarget path = adminClusters.path(cluster).path("namespaceIsolationPolicies").path("brokers");
final CompletableFuture<List<BrokerNamespaceIsolationData>> future = new CompletableFuture<>();
asyncGetRequest(path, new InvocationCallback<List<BrokerNamespaceIsolationDataImpl>>() {
@Override
public void completed(List<BrokerNamespaceIsolationDataImpl> brokerNamespaceIsolationData) {
List<BrokerNamespaceIsolationData> data = new ArrayList<>(brokerNamespaceIsolationData);
future.complete(data);
}
@Override
public void failed(Throwable throwable) {
future.completeExceptionally(getApiException(throwable.getCause()));
}
});
return future;
}
use of org.apache.pulsar.common.policies.data.BrokerNamespaceIsolationDataImpl in project pulsar by apache.
the class ClustersImpl method getBrokerWithNamespaceIsolationPolicyAsync.
@Override
public CompletableFuture<BrokerNamespaceIsolationData> getBrokerWithNamespaceIsolationPolicyAsync(String cluster, String broker) {
WebTarget path = adminClusters.path(cluster).path("namespaceIsolationPolicies").path("brokers").path(broker);
final CompletableFuture<BrokerNamespaceIsolationData> future = new CompletableFuture<>();
asyncGetRequest(path, new InvocationCallback<BrokerNamespaceIsolationDataImpl>() {
@Override
public void completed(BrokerNamespaceIsolationDataImpl brokerNamespaceIsolationData) {
future.complete(brokerNamespaceIsolationData);
}
@Override
public void failed(Throwable throwable) {
future.completeExceptionally(getApiException(throwable.getCause()));
}
});
return future;
}
use of org.apache.pulsar.common.policies.data.BrokerNamespaceIsolationDataImpl in project pulsar by yahoo.
the class ClustersImpl method getBrokerWithNamespaceIsolationPolicyAsync.
@Override
public CompletableFuture<BrokerNamespaceIsolationData> getBrokerWithNamespaceIsolationPolicyAsync(String cluster, String broker) {
WebTarget path = adminClusters.path(cluster).path("namespaceIsolationPolicies").path("brokers").path(broker);
final CompletableFuture<BrokerNamespaceIsolationData> future = new CompletableFuture<>();
asyncGetRequest(path, new InvocationCallback<BrokerNamespaceIsolationDataImpl>() {
@Override
public void completed(BrokerNamespaceIsolationDataImpl brokerNamespaceIsolationData) {
future.complete(brokerNamespaceIsolationData);
}
@Override
public void failed(Throwable throwable) {
future.completeExceptionally(getApiException(throwable.getCause()));
}
});
return future;
}
use of org.apache.pulsar.common.policies.data.BrokerNamespaceIsolationDataImpl in project incubator-pulsar by apache.
the class AdminApi2Test method brokerNamespaceIsolationPolicies.
@Test
public void brokerNamespaceIsolationPolicies() throws Exception {
// create
String policyName1 = "policy-1";
String cluster = pulsar.getConfiguration().getClusterName();
String namespaceRegex = "other/" + cluster + "/other.*";
String brokerName = pulsar.getAdvertisedAddress();
String brokerAddress = brokerName + ":" + pulsar.getConfiguration().getWebServicePort().get();
Map<String, String> parameters1 = new HashMap<>();
parameters1.put("min_limit", "1");
parameters1.put("usage_threshold", "100");
NamespaceIsolationData nsPolicyData1 = NamespaceIsolationData.builder().namespaces(Collections.singletonList(namespaceRegex)).primary(Collections.singletonList(brokerName + ":[0-9]*")).secondary(Collections.singletonList(brokerName + ".*")).autoFailoverPolicy(AutoFailoverPolicyData.builder().policyType(AutoFailoverPolicyType.min_available).parameters(parameters1).build()).build();
admin.clusters().createNamespaceIsolationPolicy(cluster, policyName1, nsPolicyData1);
List<BrokerNamespaceIsolationData> brokerIsolationDataList = admin.clusters().getBrokersWithNamespaceIsolationPolicy(cluster);
assertEquals(brokerIsolationDataList.size(), 1);
assertEquals(brokerIsolationDataList.get(0).getBrokerName(), brokerAddress);
assertEquals(brokerIsolationDataList.get(0).getNamespaceRegex().size(), 1);
assertEquals(brokerIsolationDataList.get(0).getNamespaceRegex().get(0), namespaceRegex);
assertEquals(brokerIsolationDataList.get(0).getPolicyName(), policyName1);
BrokerNamespaceIsolationDataImpl brokerIsolationData = (BrokerNamespaceIsolationDataImpl) admin.clusters().getBrokerWithNamespaceIsolationPolicy(cluster, brokerAddress);
assertEquals(brokerIsolationData.getBrokerName(), brokerAddress);
assertEquals(brokerIsolationData.getNamespaceRegex().size(), 1);
assertEquals(brokerIsolationData.getNamespaceRegex().get(0), namespaceRegex);
BrokerNamespaceIsolationDataImpl isolationData = (BrokerNamespaceIsolationDataImpl) admin.clusters().getBrokerWithNamespaceIsolationPolicy(cluster, "invalid-broker");
assertFalse(isolationData.isPrimary());
}
use of org.apache.pulsar.common.policies.data.BrokerNamespaceIsolationDataImpl in project incubator-pulsar by apache.
the class ClustersImpl method getBrokerWithNamespaceIsolationPolicyAsync.
@Override
public CompletableFuture<BrokerNamespaceIsolationData> getBrokerWithNamespaceIsolationPolicyAsync(String cluster, String broker) {
WebTarget path = adminClusters.path(cluster).path("namespaceIsolationPolicies").path("brokers").path(broker);
final CompletableFuture<BrokerNamespaceIsolationData> future = new CompletableFuture<>();
asyncGetRequest(path, new InvocationCallback<BrokerNamespaceIsolationDataImpl>() {
@Override
public void completed(BrokerNamespaceIsolationDataImpl brokerNamespaceIsolationData) {
future.complete(brokerNamespaceIsolationData);
}
@Override
public void failed(Throwable throwable) {
future.completeExceptionally(getApiException(throwable.getCause()));
}
});
return future;
}
Aggregations