@Override public boolean includes(TopicName topicName) { return this.equals(topicName.getNamespaceObject()); }
public static boolean isValid(String topic) { try { get(topic); return true; } catch (Exception e) { return false; } }
/** * Extract the namespace portion out of a completeTopicName name. * * Works both with old & new convention. * * @return the namespace */ public String getNamespace() { return namespaceName.toString(); }
private boolean topicNameValid(String topicName) { checkArgument(TopicName.isValid(topicName), "Invalid topic name:" + topicName); checkArgument(!topics.containsKey(topicName), "Topics already contains topic:" + topicName); if (this.namespaceName != null) { checkArgument(TopicName.get(topicName).getNamespace().toString().equals(this.namespaceName.toString()), "Topic " + topicName + " not in same namespace with Topics"); } return true; }
public static NamespaceName getNameSpaceFromPattern(Pattern pattern) { return TopicName.get(pattern.pattern()).getNamespaceObject(); }
public String getSchemaName() { return getTenant() + "/" + getNamespacePortion() + "/" + getEncodedLocalName(); }
public static NamespaceName get(String tenant, String cluster, String namespace) { validateNamespaceName(tenant, cluster, namespace); return get(tenant + '/' + cluster + '/' + namespace); }
@Override public NamespaceName load(String name) throws Exception { return new NamespaceName(name); } });
@Override public TopicName load(String name) throws Exception { return new TopicName(name); } });
@Override public boolean includes(TopicName otherTopicName) { return this.equals(otherTopicName); }
public String getPersistentTopicName(String localTopic) { return getTopicName(TopicDomain.persistent, localTopic); }
/** * For partitions in a topic, return the base partitioned topic name * Eg: * <ul> * <li><code>persistent://prop/cluster/ns/my-topic-partition-1</code> --> <code>persistent://prop/cluster/ns/my-topic</code> * <li><code>persistent://prop/cluster/ns/my-topic</code> --> <code>persistent://prop/cluster/ns/my-topic</code> * </ul> */ public String getPartitionedTopicName() { if (isPartitioned()) { return completeTopicName.substring(0, completeTopicName.lastIndexOf("-partition-")); } else { return completeTopicName; } }
public static TopicName get(String domain, String tenant, String namespace, String topic) { String name = domain + "://" + tenant + '/' + namespace + '/' + topic; return TopicName.get(name); }
private boolean namespaceMatches(NamespaceName namespace, NamespaceIsolationData nsPolicyData) { for (String nsnameRegex : nsPolicyData.namespaces) { if (namespace.toString().matches(nsnameRegex)) { return true; } } return false; }
public static NamespaceName get(String tenant, String namespace) { validateNamespaceName(tenant, namespace); return get(tenant + '/' + namespace); }
public static TopicName get(String domain, String tenant, String cluster, String namespace, String topic) { String name = domain + "://" + tenant + '/' + cluster + '/' + namespace + '/' + topic; return TopicName.get(name); }
public PersistentOfflineTopicStats getEstimatedUnloadedTopicBacklog(ManagedLedgerFactoryImpl factory, String managedLedgerName) throws Exception { return estimateUnloadedTopicBacklog(factory, TopicName.get("persistent://" + managedLedgerName)); }
public static MessageId fromByteArrayWithTopic(byte[] data, String topicName) throws IOException { return fromByteArrayWithTopic(data, TopicName.get(topicName)); }