use of org.apache.pulsar.common.naming.NamespaceName in project incubator-pulsar by apache.
the class NamespacesImpl method revokePermissionsOnNamespace.
@Override
public void revokePermissionsOnNamespace(String namespace, String role) throws PulsarAdminException {
try {
NamespaceName ns = NamespaceName.get(namespace);
WebTarget path = namespacePath(ns, "permissions", role);
request(path).delete(ErrorData.class);
} catch (Exception e) {
throw getApiException(e);
}
}
use of org.apache.pulsar.common.naming.NamespaceName in project incubator-pulsar by apache.
the class NamespacesImpl method getBacklogQuotaMap.
@Override
public Map<BacklogQuotaType, BacklogQuota> getBacklogQuotaMap(String namespace) throws PulsarAdminException {
try {
NamespaceName ns = NamespaceName.get(namespace);
WebTarget path = namespacePath(ns, "backlogQuotaMap");
return request(path).get(new GenericType<Map<BacklogQuotaType, BacklogQuota>>() {
});
} catch (Exception e) {
throw getApiException(e);
}
}
use of org.apache.pulsar.common.naming.NamespaceName in project incubator-pulsar by apache.
the class NamespacesImpl method setDeduplicationStatus.
@Override
public void setDeduplicationStatus(String namespace, boolean enableDeduplication) throws PulsarAdminException {
try {
NamespaceName ns = NamespaceName.get(namespace);
WebTarget path = namespacePath(ns, "deduplication");
request(path).post(Entity.entity(enableDeduplication, MediaType.APPLICATION_JSON), ErrorData.class);
} catch (Exception e) {
throw getApiException(e);
}
}
use of org.apache.pulsar.common.naming.NamespaceName in project incubator-pulsar by apache.
the class NamespacesImpl method getTopics.
@Override
public List<String> getTopics(String namespace) throws PulsarAdminException {
try {
NamespaceName ns = NamespaceName.get(namespace);
WebTarget path = namespacePath(ns, "destinations");
return request(path).get(new GenericType<List<String>>() {
});
} catch (Exception e) {
throw getApiException(e);
}
}
use of org.apache.pulsar.common.naming.NamespaceName in project incubator-pulsar by apache.
the class NamespaceService method registerNamespace.
/**
* Tried to registers a namespace to this instance
*
* @param namespace
* @param ensureOwned
* @return
* @throws PulsarServerException
* @throws Exception
*/
private boolean registerNamespace(String namespace, boolean ensureOwned) throws PulsarServerException {
String myUrl = pulsar.getBrokerServiceUrl();
try {
NamespaceName nsname = NamespaceName.get(namespace);
String otherUrl = null;
NamespaceBundle nsFullBundle = null;
// all pre-registered namespace is assumed to have bundles disabled
nsFullBundle = bundleFactory.getFullBundle(nsname);
// v2 namespace will always use full bundle object
otherUrl = ownershipCache.tryAcquiringOwnership(nsFullBundle).get().getNativeUrl();
if (myUrl.equals(otherUrl)) {
if (nsFullBundle != null) {
// preload heartbeat namespace
pulsar.loadNamespaceTopics(nsFullBundle);
}
return true;
}
String msg = String.format("namespace already owned by other broker : ns=%s expected=%s actual=%s", namespace, myUrl, otherUrl);
// ignore if not be owned for now
if (!ensureOwned) {
LOG.info(msg);
return false;
}
// should not happen
throw new IllegalStateException(msg);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new PulsarServerException(e);
}
}
Aggregations