本文整理了Java中org.apache.pulsar.zookeeper.ZooKeeperDataCache.invalidate()
方法的一些代码示例,展示了ZooKeeperDataCache.invalidate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperDataCache.invalidate()
方法的具体详情如下:
包路径:org.apache.pulsar.zookeeper.ZooKeeperDataCache
类名称:ZooKeeperDataCache
方法名:invalidate
暂无
代码示例来源:origin: org.apache.pulsar/pulsar-broker
/**
* Set resource quota for a specified <code>ServiceUnit</code>.
*
* @param suName
* identifier of the <code>ServiceUnit</code>
* @param quota
* <code>ResourceQuota</code> to set.
*/
public void setQuota(String suName, ResourceQuota quota) throws Exception {
String zpath = ResourceQuotaCache.path(suName);
this.resourceQuotaCache.invalidate(zpath);
this.saveQuotaToZnode(zpath, quota);
}
代码示例来源:origin: org.apache.pulsar/pulsar-broker
/**
* Disable bundle in local cache and on zk
*
* @param bundle
* @throws Exception
*/
public void disableOwnership(NamespaceBundle bundle) throws Exception {
String path = ServiceUnitZkUtils.path(bundle);
updateBundleState(bundle, false);
localZkCache.getZooKeeper().setData(path, jsonMapper.writeValueAsBytes(selfOwnerInfoDisabled), -1);
ownershipReadOnlyCache.invalidate(path);
}
代码示例来源:origin: org.apache.pulsar/pulsar-broker-common
configCache.policiesCache().invalidate(policiesPath);
代码示例来源:origin: org.apache.pulsar/pulsar-broker
LOG.debug("Successfully acquired zk lock on {}", namespaceBundleZNode);
ownershipReadOnlyCache.invalidate(namespaceBundleZNode);
future.complete(new OwnedBundle(
ServiceUnitZkUtils.suBundleFromPath(namespaceBundleZNode, bundleFactory)));
代码示例来源:origin: org.apache.pulsar/pulsar-broker
/**
* Method to remove the ownership of local broker on the <code>NamespaceBundle</code>, if owned
*
*/
public CompletableFuture<Void> removeOwnership(NamespaceBundle bundle) {
CompletableFuture<Void> result = new CompletableFuture<>();
String key = ServiceUnitZkUtils.path(bundle);
localZkCache.getZooKeeper().delete(key, -1, (rc, path, ctx) -> {
if (rc == KeeperException.Code.OK.intValue() || rc == KeeperException.Code.NONODE.intValue()) {
LOG.info("[{}] Removed zk lock for service unit: {}", key, KeeperException.Code.get(rc));
ownedBundlesCache.synchronous().invalidate(key);
ownershipReadOnlyCache.invalidate(key);
result.complete(null);
} else {
LOG.warn("[{}] Failed to delete the namespace ephemeral node. key={}", key,
KeeperException.Code.get(rc));
result.completeExceptionally(KeeperException.create(rc));
}
}, null);
return result;
}
代码示例来源:origin: org.apache.pulsar/pulsar-broker
@DELETE
@Path("/{cluster}/failureDomains/{domainName}")
@ApiOperation(value = "Delete cluster's failure omain")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission or plicy is read only"),
@ApiResponse(code = 412, message = "Cluster doesn't exist") })
public void deleteFailureDomain(@PathParam("cluster") String cluster, @PathParam("domainName") String domainName)
throws Exception {
validateSuperUserAccess();
validateClusterExists(cluster);
try {
final String domainPath = joinPath(pulsar().getConfigurationCache().CLUSTER_FAILURE_DOMAIN_ROOT, domainName);
globalZk().delete(domainPath, -1);
// clear domain cache
failureDomainCache().invalidate(domainPath);
failureDomainListCache().clear();
} catch (KeeperException.NoNodeException nne) {
log.warn("[{}] Domain {} does not exist in {}", clientAppId(), domainName, cluster);
throw new RestException(Status.NOT_FOUND,
"Domain-name " + domainName + " or cluster " + cluster + " does not exist");
} catch (Exception e) {
log.error("[{}] Failed to delete domain {} in cluster {}", clientAppId(), domainName, cluster, e);
throw new RestException(e);
}
}
代码示例来源:origin: org.apache.pulsar/pulsar-broker
policiesCache().invalidate(path);
代码示例来源:origin: org.apache.pulsar/pulsar-broker
policiesCache().invalidate(path);
代码示例来源:origin: org.apache.pulsar/pulsar-broker
protected void internalCreateNamespace(Policies policies) {
validatePoliciesReadOnlyAccess();
validateAdminAccessForTenant(namespaceName.getTenant());
validatePolicies(namespaceName, policies);
try {
policiesCache().invalidate(path(POLICIES, namespaceName.toString()));
zkCreateOptimistic(path(POLICIES, namespaceName.toString()), jsonMapper().writeValueAsBytes(policies));
log.info("[{}] Created namespace {}", clientAppId(), namespaceName);
} catch (KeeperException.NodeExistsException e) {
log.warn("[{}] Failed to create namespace {} - already exists", clientAppId(), namespaceName);
throw new RestException(Status.CONFLICT, "Namespace already exists");
} catch (Exception e) {
log.error("[{}] Failed to create namespace {}", clientAppId(), namespaceName, e);
throw new RestException(e);
}
}
代码示例来源:origin: org.apache.pulsar/pulsar-broker
protected void internalRemoveNamespaceAntiAffinityGroup() {
validateAdminAccessForTenant(namespaceName.getTenant());
validatePoliciesReadOnlyAccess();
log.info("[{}] Deleting anti-affinity group for {}", clientAppId(), namespaceName);
try {
Stat nodeStat = new Stat();
final String path = path(POLICIES, namespaceName.toString());
byte[] content = globalZk().getData(path, null, nodeStat);
Policies policies = jsonMapper().readValue(content, Policies.class);
policies.antiAffinityGroup = null;
globalZk().setData(path, jsonMapper().writeValueAsBytes(policies), nodeStat.getVersion());
policiesCache().invalidate(path(POLICIES, namespaceName.toString()));
log.info("[{}] Successfully removed anti-affinity group for a namespace={}", clientAppId(), namespaceName);
} catch (KeeperException.NoNodeException e) {
log.warn("[{}] Failed to remove anti-affinity group for namespace {}: does not exist", clientAppId(),
namespaceName);
throw new RestException(Status.NOT_FOUND, "Namespace does not exist");
} catch (KeeperException.BadVersionException e) {
log.warn("[{}] Failed to remove anti-affinity group for namespace {}: concurrent modification",
clientAppId(), namespaceName);
throw new RestException(Status.CONFLICT, "Concurrent modification");
} catch (Exception e) {
log.error("[{}] Failed to remove anti-affinity group for namespace {}", clientAppId(), namespaceName, e);
throw new RestException(e);
}
}
代码示例来源:origin: org.apache.pulsar/pulsar-broker
protected void internalRevokePermissionsOnNamespace(String role) {
validateAdminAccessForTenant(namespaceName.getTenant());
validatePoliciesReadOnlyAccess();
try {
Stat nodeStat = new Stat();
byte[] content = globalZk().getData(path(POLICIES, namespaceName.toString()), null, nodeStat);
Policies policies = jsonMapper().readValue(content, Policies.class);
policies.auth_policies.namespace_auth.remove(role);
// Write back the new policies into zookeeper
globalZk().setData(path(POLICIES, namespaceName.toString()), jsonMapper().writeValueAsBytes(policies),
nodeStat.getVersion());
policiesCache().invalidate(path(POLICIES, namespaceName.toString()));
log.info("[{}] Successfully revoked access for role {} - namespace {}", clientAppId(), role, namespaceName);
} catch (KeeperException.NoNodeException e) {
log.warn("[{}] Failed to revoke permissions for namespace {}: does not exist", clientAppId(),
namespaceName);
throw new RestException(Status.NOT_FOUND, "Namespace does not exist");
} catch (KeeperException.BadVersionException e) {
log.warn("[{}] Failed to revoke permissions on namespace {}: concurrent modification", clientAppId(),
namespaceName);
throw new RestException(Status.CONFLICT, "Concurrent modification");
} catch (Exception e) {
log.error("[{}] Failed to revoke permissions on namespace {}", clientAppId(), namespaceName, e);
throw new RestException(e);
}
}
代码示例来源:origin: org.apache.pulsar/pulsar-broker
/**
* Update new bundle-range to LocalZk (create a new node if not present).
* Update may fail because of concurrent write to Zookeeper.
*
* @param nsname
* @param nsBundles
* @param callback
* @throws Exception
*/
private void updateNamespaceBundles(NamespaceName nsname, NamespaceBundles nsBundles, StatCallback callback)
throws Exception {
checkNotNull(nsname);
checkNotNull(nsBundles);
String path = joinPath(LOCAL_POLICIES_ROOT, nsname.toString());
Optional<LocalPolicies> policies = pulsar.getLocalZkCacheService().policiesCache().get(path);
if (!policies.isPresent()) {
// if policies is not present into localZk then create new policies
this.pulsar.getLocalZkCacheService().createPolicies(path, false).get(cacheTimeOutInSec, SECONDS);
}
long version = nsBundles.getVersion();
LocalPolicies local = new LocalPolicies();
local.bundles = getBundlesData(nsBundles);
byte[] data = ObjectMapperFactory.getThreadLocal().writeValueAsBytes(local);
this.pulsar.getLocalZkCache().getZooKeeper()
.setData(path, data, Math.toIntExact(version), callback, null);
// invalidate namespace's local-policies
this.pulsar.getLocalZkCacheService().policiesCache().invalidate(path);
}
代码示例来源:origin: org.apache.pulsar/pulsar-broker
protected void internalModifyDeduplication(boolean enableDeduplication) {
validateAdminAccessForTenant(namespaceName.getTenant());
validatePoliciesReadOnlyAccess();
Entry<Policies, Stat> policiesNode = null;
try {
// Force to read the data s.t. the watch to the cache content is setup.
policiesNode = policiesCache().getWithStat(path(POLICIES, namespaceName.toString())).orElseThrow(
() -> new RestException(Status.NOT_FOUND, "Namespace " + namespaceName + " does not exist"));
policiesNode.getKey().deduplicationEnabled = enableDeduplication;
// Write back the new policies into zookeeper
globalZk().setData(path(POLICIES, namespaceName.toString()),
jsonMapper().writeValueAsBytes(policiesNode.getKey()), policiesNode.getValue().getVersion());
policiesCache().invalidate(path(POLICIES, namespaceName.toString()));
log.info("[{}] Successfully {} on namespace {}", clientAppId(),
enableDeduplication ? "enabled" : "disabled", namespaceName);
} catch (KeeperException.NoNodeException e) {
log.warn("[{}] Failed to modify deplication status for namespace {}: does not exist", clientAppId(),
namespaceName);
throw new RestException(Status.NOT_FOUND, "Namespace does not exist");
} catch (KeeperException.BadVersionException e) {
log.warn(
"[{}] Failed to modify deplication status on namespace {} expected policy node version={} : concurrent modification",
clientAppId(), namespaceName, policiesNode.getValue().getVersion());
throw new RestException(Status.CONFLICT, "Concurrent modification");
} catch (Exception e) {
log.error("[{}] Failed to modify deplication status on namespace {}", clientAppId(), namespaceName, e);
throw new RestException(e);
}
}
代码示例来源:origin: org.apache.pulsar/pulsar-broker
protected void internalSetOffloadThreshold(long newThreshold) {
validateSuperUserAccess();
validatePoliciesReadOnlyAccess();
try {
Stat nodeStat = new Stat();
final String path = path(POLICIES, namespaceName.toString());
byte[] content = globalZk().getData(path, null, nodeStat);
Policies policies = jsonMapper().readValue(content, Policies.class);
policies.offload_threshold = newThreshold;
globalZk().setData(path, jsonMapper().writeValueAsBytes(policies), nodeStat.getVersion());
policiesCache().invalidate(path(POLICIES, namespaceName.toString()));
log.info("[{}] Successfully updated offloadThreshold configuration: namespace={}, value={}",
clientAppId(), namespaceName, policies.offload_threshold);
} catch (KeeperException.NoNodeException e) {
log.warn("[{}] Failed to update offloadThreshold configuration for namespace {}: does not exist",
clientAppId(), namespaceName);
throw new RestException(Status.NOT_FOUND, "Namespace does not exist");
} catch (KeeperException.BadVersionException e) {
log.warn("[{}] Failed to update offloadThreshold configuration for namespace {}: concurrent modification",
clientAppId(), namespaceName);
throw new RestException(Status.CONFLICT, "Concurrent modification");
} catch (RestException pfe) {
throw pfe;
} catch (Exception e) {
log.error("[{}] Failed to update offloadThreshold configuration for namespace {}",
clientAppId(), namespaceName, e);
throw new RestException(e);
}
}
代码示例来源:origin: org.apache.pulsar/pulsar-broker
protected void internalSetOffloadDeletionLag(Long newDeletionLagMs) {
validateSuperUserAccess();
validatePoliciesReadOnlyAccess();
try {
Stat nodeStat = new Stat();
final String path = path(POLICIES, namespaceName.toString());
byte[] content = globalZk().getData(path, null, nodeStat);
Policies policies = jsonMapper().readValue(content, Policies.class);
policies.offload_deletion_lag_ms = newDeletionLagMs;
globalZk().setData(path, jsonMapper().writeValueAsBytes(policies), nodeStat.getVersion());
policiesCache().invalidate(path(POLICIES, namespaceName.toString()));
log.info("[{}] Successfully updated offloadDeletionLagMs configuration: namespace={}, value={}",
clientAppId(), namespaceName, policies.offload_deletion_lag_ms);
} catch (KeeperException.NoNodeException e) {
log.warn("[{}] Failed to update offloadDeletionLagMs configuration for namespace {}: does not exist",
clientAppId(), namespaceName);
throw new RestException(Status.NOT_FOUND, "Namespace does not exist");
} catch (KeeperException.BadVersionException e) {
log.warn("[{}] Failed to update offloadDeletionLagMs configuration for namespace {}: concurrent modification",
clientAppId(), namespaceName);
throw new RestException(Status.CONFLICT, "Concurrent modification");
} catch (RestException pfe) {
throw pfe;
} catch (Exception e) {
log.error("[{}] Failed to update offloadDeletionLag configuration for namespace {}",
clientAppId(), namespaceName, e);
throw new RestException(e);
}
}
代码示例来源:origin: org.apache.pulsar/pulsar-broker
policies.subscription_auth_mode = subscriptionAuthMode;
globalZk().setData(path, jsonMapper().writeValueAsBytes(policies), nodeStat.getVersion());
policiesCache().invalidate(path(POLICIES, namespaceName.toString()));
log.info("[{}] Successfully updated subscription auth mode: namespace={}, map={}", clientAppId(),
namespaceName, jsonMapper().writeValueAsString(policies.backlog_quota_map));
代码示例来源:origin: org.apache.pulsar/pulsar-broker
policiesCache().invalidate(path(POLICIES, namespaceName.toString()));
log.info("[{}] Successfully updated maxConsumersPerTopic configuration: namespace={}, value={}", clientAppId(),
namespaceName, policies.max_consumers_per_topic);
代码示例来源:origin: org.apache.pulsar/pulsar-broker
policiesCache().invalidate(path(POLICIES, namespaceName.toString()));
代码示例来源:origin: org.apache.pulsar/pulsar-broker
policiesCache().invalidate(path(POLICIES, namespaceName.toString()));
log.info("[{}] Successfully updated retention configuration: namespace={}, map={}", clientAppId(),
namespaceName, jsonMapper().writeValueAsString(policies.retention_policies));
代码示例来源:origin: org.apache.pulsar/pulsar-broker
protected void internalSetPersistence(PersistencePolicies persistence) {
validateAdminAccessForTenant(namespaceName.getTenant());
validatePoliciesReadOnlyAccess();
validatePersistencePolicies(persistence);
try {
Stat nodeStat = new Stat();
final String path = path(POLICIES, namespaceName.toString());
byte[] content = globalZk().getData(path, null, nodeStat);
Policies policies = jsonMapper().readValue(content, Policies.class);
policies.persistence = persistence;
globalZk().setData(path, jsonMapper().writeValueAsBytes(policies), nodeStat.getVersion());
policiesCache().invalidate(path(POLICIES, namespaceName.toString()));
log.info("[{}] Successfully updated persistence configuration: namespace={}, map={}", clientAppId(),
namespaceName, jsonMapper().writeValueAsString(policies.persistence));
} catch (KeeperException.NoNodeException e) {
log.warn("[{}] Failed to update persistence configuration for namespace {}: does not exist", clientAppId(),
namespaceName);
throw new RestException(Status.NOT_FOUND, "Namespace does not exist");
} catch (KeeperException.BadVersionException e) {
log.warn("[{}] Failed to update persistence configuration for namespace {}: concurrent modification",
clientAppId(), namespaceName);
throw new RestException(Status.CONFLICT, "Concurrent modification");
} catch (Exception e) {
log.error("[{}] Failed to update persistence configuration for namespace {}", clientAppId(), namespaceName,
e);
throw new RestException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!