use of org.apache.pulsar.common.policies.data.TransactionCoordinatorInternalStats in project pulsar by apache.
the class AdminApiTransactionTest method testGetCoordinatorInternalStats.
@Test(timeOut = 20000)
public void testGetCoordinatorInternalStats() throws Exception {
initTransaction(1);
Transaction transaction = pulsarClient.newTransaction().withTransactionTimeout(60, TimeUnit.SECONDS).build().get();
TransactionCoordinatorInternalStats stats = admin.transactions().getCoordinatorInternalStatsAsync(0, true).get();
verifyManagedLegerInternalStats(stats.transactionLogStats.managedLedgerInternalStats, 26);
assertEquals(TopicName.get(TopicDomain.persistent.toString(), NamespaceName.SYSTEM_NAMESPACE, MLTransactionLogImpl.TRANSACTION_LOG_PREFIX + "0").getPersistenceNamingEncoding(), stats.transactionLogStats.managedLedgerName);
transaction.commit().get();
stats = admin.transactions().getCoordinatorInternalStatsAsync(0, false).get();
assertNull(stats.transactionLogStats.managedLedgerInternalStats.ledgers.get(0).metadata);
assertEquals(TopicName.get(TopicDomain.persistent.toString(), NamespaceName.SYSTEM_NAMESPACE, MLTransactionLogImpl.TRANSACTION_LOG_PREFIX + "0").getPersistenceNamingEncoding(), stats.transactionLogStats.managedLedgerName);
}
use of org.apache.pulsar.common.policies.data.TransactionCoordinatorInternalStats in project pulsar by apache.
the class TransactionsBase method internalGetCoordinatorInternalStats.
protected void internalGetCoordinatorInternalStats(AsyncResponse asyncResponse, boolean authoritative, boolean metadata, int coordinatorId) {
try {
if (pulsar().getConfig().isTransactionCoordinatorEnabled()) {
TopicName topicName = TopicName.TRANSACTION_COORDINATOR_ASSIGN.getPartition(coordinatorId);
validateTopicOwnership(topicName, authoritative);
TransactionMetadataStore metadataStore = pulsar().getTransactionMetadataStoreService().getStores().get(TransactionCoordinatorID.get(coordinatorId));
if (metadataStore == null) {
asyncResponse.resume(new RestException(NOT_FOUND, "Transaction coordinator not found! coordinator id : " + coordinatorId));
return;
}
if (metadataStore instanceof MLTransactionMetadataStore) {
ManagedLedger managedLedger = ((MLTransactionMetadataStore) metadataStore).getManagedLedger();
TransactionCoordinatorInternalStats transactionCoordinatorInternalStats = new TransactionCoordinatorInternalStats();
TransactionLogStats transactionLogStats = new TransactionLogStats();
transactionLogStats.managedLedgerName = managedLedger.getName();
transactionLogStats.managedLedgerInternalStats = managedLedger.getManagedLedgerInternalStats(metadata).get();
transactionCoordinatorInternalStats.transactionLogStats = transactionLogStats;
asyncResponse.resume(transactionCoordinatorInternalStats);
} else {
asyncResponse.resume(new RestException(METHOD_NOT_ALLOWED, "Broker don't use MLTransactionMetadataStore!"));
}
} else {
asyncResponse.resume(new RestException(SERVICE_UNAVAILABLE, "This Broker is not configured with transactionCoordinatorEnabled=true."));
}
} catch (Exception e) {
asyncResponse.resume(new RestException(e.getCause()));
}
}
use of org.apache.pulsar.common.policies.data.TransactionCoordinatorInternalStats in project pulsar by yahoo.
the class AdminApiTransactionTest method testGetCoordinatorInternalStats.
@Test(timeOut = 20000)
public void testGetCoordinatorInternalStats() throws Exception {
initTransaction(1);
Transaction transaction = pulsarClient.newTransaction().withTransactionTimeout(60, TimeUnit.SECONDS).build().get();
TransactionCoordinatorInternalStats stats = admin.transactions().getCoordinatorInternalStatsAsync(0, true).get();
verifyManagedLegerInternalStats(stats.transactionLogStats.managedLedgerInternalStats, 26);
assertEquals(TopicName.get(TopicDomain.persistent.toString(), NamespaceName.SYSTEM_NAMESPACE, MLTransactionLogImpl.TRANSACTION_LOG_PREFIX + "0").getPersistenceNamingEncoding(), stats.transactionLogStats.managedLedgerName);
transaction.commit().get();
stats = admin.transactions().getCoordinatorInternalStatsAsync(0, false).get();
assertNull(stats.transactionLogStats.managedLedgerInternalStats.ledgers.get(0).metadata);
assertEquals(TopicName.get(TopicDomain.persistent.toString(), NamespaceName.SYSTEM_NAMESPACE, MLTransactionLogImpl.TRANSACTION_LOG_PREFIX + "0").getPersistenceNamingEncoding(), stats.transactionLogStats.managedLedgerName);
}
use of org.apache.pulsar.common.policies.data.TransactionCoordinatorInternalStats in project incubator-pulsar by apache.
the class AdminApiTransactionTest method testGetCoordinatorInternalStats.
@Test(timeOut = 20000)
public void testGetCoordinatorInternalStats() throws Exception {
initTransaction(1);
Transaction transaction = pulsarClient.newTransaction().withTransactionTimeout(60, TimeUnit.SECONDS).build().get();
TransactionCoordinatorInternalStats stats = admin.transactions().getCoordinatorInternalStatsAsync(0, true).get();
verifyManagedLegerInternalStats(stats.transactionLogStats.managedLedgerInternalStats, 26);
assertEquals(TopicName.get(TopicDomain.persistent.toString(), NamespaceName.SYSTEM_NAMESPACE, MLTransactionLogImpl.TRANSACTION_LOG_PREFIX + "0").getPersistenceNamingEncoding(), stats.transactionLogStats.managedLedgerName);
transaction.commit().get();
stats = admin.transactions().getCoordinatorInternalStatsAsync(0, false).get();
assertNull(stats.transactionLogStats.managedLedgerInternalStats.ledgers.get(0).metadata);
assertEquals(TopicName.get(TopicDomain.persistent.toString(), NamespaceName.SYSTEM_NAMESPACE, MLTransactionLogImpl.TRANSACTION_LOG_PREFIX + "0").getPersistenceNamingEncoding(), stats.transactionLogStats.managedLedgerName);
}
use of org.apache.pulsar.common.policies.data.TransactionCoordinatorInternalStats in project incubator-pulsar by apache.
the class TransactionsBase method internalGetCoordinatorInternalStats.
protected void internalGetCoordinatorInternalStats(AsyncResponse asyncResponse, boolean authoritative, boolean metadata, int coordinatorId) {
try {
TopicName topicName = SystemTopicNames.TRANSACTION_COORDINATOR_ASSIGN.getPartition(coordinatorId);
validateTopicOwnership(topicName, authoritative);
TransactionMetadataStore metadataStore = pulsar().getTransactionMetadataStoreService().getStores().get(TransactionCoordinatorID.get(coordinatorId));
if (metadataStore == null) {
asyncResponse.resume(new RestException(NOT_FOUND, "Transaction coordinator not found! coordinator id : " + coordinatorId));
return;
}
if (metadataStore instanceof MLTransactionMetadataStore) {
ManagedLedger managedLedger = ((MLTransactionMetadataStore) metadataStore).getManagedLedger();
TransactionCoordinatorInternalStats transactionCoordinatorInternalStats = new TransactionCoordinatorInternalStats();
TransactionLogStats transactionLogStats = new TransactionLogStats();
transactionLogStats.managedLedgerName = managedLedger.getName();
transactionLogStats.managedLedgerInternalStats = managedLedger.getManagedLedgerInternalStats(metadata).get();
transactionCoordinatorInternalStats.transactionLogStats = transactionLogStats;
asyncResponse.resume(transactionCoordinatorInternalStats);
} else {
asyncResponse.resume(new RestException(METHOD_NOT_ALLOWED, "Broker don't use MLTransactionMetadataStore!"));
}
} catch (Exception e) {
resumeAsyncResponseExceptionally(asyncResponse, e);
}
}
Aggregations