Skip to content

Commit

Permalink
[Java] Generate separate version info for ConsensusModule, ClusterBac…
Browse files Browse the repository at this point in the history
…kup and ClusteredServiceContainer.
  • Loading branch information
vyazelenko committed Nov 7, 2023
1 parent 3b33569 commit 5c37823
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 13 deletions.
11 changes: 10 additions & 1 deletion aeron-cluster/src/main/java/io/aeron/cluster/ClusterBackup.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.aeron.exceptions.ConfigurationException;
import io.aeron.security.CredentialsSupplier;
import io.aeron.security.NullCredentialsSupplier;
import io.aeron.version.Versioned;
import org.agrona.CloseHelper;
import org.agrona.ErrorHandler;
import org.agrona.ExpandableArrayBuffer;
Expand Down Expand Up @@ -55,6 +56,7 @@
/**
* Backup component which can run remote from a cluster which polls for snapshots and replicates the log.
*/
@Versioned
public final class ClusterBackup implements AutoCloseable
{
/**
Expand Down Expand Up @@ -665,7 +667,13 @@ public void conclude()
if (null == errorCounter)
{
errorCounter = ClusterCounters.allocateVersioned(
aeron, buffer, "ClusterBackup Errors", CLUSTER_BACKUP_ERROR_COUNT_TYPE_ID, clusterId);
aeron,
buffer,
"ClusterBackup Errors",
CLUSTER_BACKUP_ERROR_COUNT_TYPE_ID,
clusterId,
ClusterBackupVersion.VERSION,
ClusterBackupVersion.GIT_SHA);
}
}

Expand Down Expand Up @@ -1719,6 +1727,7 @@ public Context sourceType(final SourceType sourceType)

/**
* Get the currently configured source type
*
* @return source type for this backup instance.
* @throws IllegalArgumentException if the configured source type is not one of {@link SourceType}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import io.aeron.security.AuthorisationService;
import io.aeron.security.AuthorisationServiceSupplier;
import io.aeron.security.DefaultAuthenticatorSupplier;
import io.aeron.version.Versioned;
import org.agrona.*;
import org.agrona.concurrent.*;
import org.agrona.concurrent.errors.DistinctErrorLog;
Expand All @@ -59,6 +60,7 @@
import static io.aeron.AeronCounters.NODE_CONTROL_TOGGLE_TYPE_ID;
import static io.aeron.AeronCounters.validateCounterTypeId;
import static io.aeron.CommonContext.*;
import static io.aeron.cluster.ConsensusModule.Configuration.CLUSTER_CLIENT_TIMEOUT_COUNT_TYPE_ID;
import static io.aeron.cluster.ConsensusModule.Configuration.CLUSTER_NODE_ROLE_TYPE_ID;
import static io.aeron.cluster.ConsensusModule.Configuration.COMMIT_POSITION_TYPE_ID;
import static io.aeron.cluster.ConsensusModule.Configuration.*;
Expand All @@ -72,6 +74,7 @@
* Component which resides on each node and is responsible for coordinating consensus within a cluster in concert
* with the lifecycle of clustered services.
*/
@Versioned
public final class ConsensusModule implements AutoCloseable
{
/**
Expand Down Expand Up @@ -1584,7 +1587,13 @@ public void conclude()
if (null == errorCounter)
{
errorCounter = ClusterCounters.allocateVersioned(
aeron, buffer, "Cluster Errors", CONSENSUS_MODULE_ERROR_COUNT_TYPE_ID, clusterId);
aeron,
buffer,
"Cluster Errors",
CONSENSUS_MODULE_ERROR_COUNT_TYPE_ID,
clusterId,
ConsensusModuleVersion.VERSION,
ConsensusModuleVersion.GIT_SHA);
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import io.aeron.cluster.codecs.CloseReason;
import io.aeron.logbuffer.BufferClaim;
import io.aeron.logbuffer.Header;
import io.aeron.version.Versioned;
import org.agrona.DirectBuffer;
import org.agrona.concurrent.IdleStrategy;
import org.agrona.concurrent.status.AtomicCounter;
Expand All @@ -44,7 +43,6 @@
* {@link ClusteredService#onSessionClose(ClientSession, long, CloseReason)},
* and {@link ClusteredService#onNewLeadershipTermEvent(long, long, long, long, int, int, TimeUnit, int)}.
*/
@Versioned
public interface Cluster
{
/**
Expand Down Expand Up @@ -111,7 +109,6 @@ public static Role get(final long code)
* Get the role by reading the code from a counter.
*
* @param counter containing the value of the role.
*
* @return the role for the cluster member.
*/
public static Role get(final AtomicCounter counter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,23 @@ public static Counter allocate(
/**
* Allocate a counter to represent component state within a cluster and append a version info to its label.
*
* @param aeron to allocate the counter.
* @param tempBuffer temporary storage to create label and metadata.
* @param name of the counter for the label.
* @param typeId for the counter.
* @param clusterId to which the allocated counter belongs.
* @param aeron to allocate the counter.
* @param tempBuffer temporary storage to create label and metadata.
* @param name of the counter for the label.
* @param typeId for the counter.
* @param clusterId to which the allocated counter belongs.
* @param version of the component.
* @param commitHashCode Git commit SHA of the component.
* @return the new {@link Counter}.
*/
public static Counter allocateVersioned(
final Aeron aeron,
final MutableDirectBuffer tempBuffer,
final String name,
final int typeId,
final int clusterId)
final int clusterId,
final String version,
final String commitHashCode)
{
int index = 0;
tempBuffer.putInt(index, clusterId);
Expand All @@ -89,7 +93,7 @@ public static Counter allocateVersioned(
index += tempBuffer.putStringWithoutLengthAscii(index, name);
index += tempBuffer.putStringWithoutLengthAscii(index, " - clusterId=");
index += tempBuffer.putIntAscii(index, clusterId);
index += AeronCounters.appendVersionInfo(tempBuffer, index, ClusterVersion.VERSION, ClusterVersion.GIT_SHA);
index += AeronCounters.appendVersionInfo(tempBuffer, index, version, commitHashCode);

return aeron.addCounter(typeId, tempBuffer, 0, keyLength, tempBuffer, keyLength, index - keyLength);
}
Expand Down Expand Up @@ -180,7 +184,8 @@ static Counter allocateServiceErrorCounter(
index += tempBuffer.putIntAscii(index, clusterId);
index += tempBuffer.putStringWithoutLengthAscii(index, " serviceId=");
index += tempBuffer.putIntAscii(index, serviceId);
index += AeronCounters.appendVersionInfo(tempBuffer, index, ClusterVersion.VERSION, ClusterVersion.GIT_SHA);
index += AeronCounters.appendVersionInfo(
tempBuffer, index, ClusteredServiceContainerVersion.VERSION, ClusteredServiceContainerVersion.GIT_SHA);

return aeron.addCounter(
AeronCounters.CLUSTER_CLUSTERED_SERVICE_ERROR_COUNT_TYPE_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.aeron.driver.status.DutyCycleStallTracker;
import io.aeron.exceptions.ConcurrentConcludeException;
import io.aeron.exceptions.ConfigurationException;
import io.aeron.version.Versioned;
import org.agrona.*;
import org.agrona.concurrent.*;
import org.agrona.concurrent.errors.DistinctErrorLog;
Expand All @@ -48,6 +49,7 @@
* loaded via {@link ClusteredServiceContainer.Configuration#SERVICE_CLASS_NAME_PROP_NAME} or
* {@link ClusteredServiceContainer.Context#clusteredService(ClusteredService)}.
*/
@Versioned
public final class ClusteredServiceContainer implements AutoCloseable
{
/**
Expand Down

0 comments on commit 5c37823

Please sign in to comment.