Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metric sync_delta and sync_all with datacenter label #298

Merged
merged 4 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public DataType getDataType() {
@Override
protected synchronized String getOtherInfo() {
return StringFormatter.format(
"scope={},elementType={},ctx={}", scope, elementType, lastPushContexts);
"scope={},elementType={},multi={},ctx={}", scope, elementType, acceptMulti, lastPushContexts);
}

public synchronized String printPushContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import com.alipay.sofa.registry.server.data.multi.cluster.slot.MultiClusterSlotManager;
import com.alipay.sofa.registry.server.shared.remoting.AbstractClientHandler;
import com.alipay.sofa.registry.util.ParaCheckUtil;

import java.util.Set;
import java.util.concurrent.Executor;
import org.springframework.beans.factory.annotation.Autowired;

Expand Down Expand Up @@ -85,12 +87,12 @@ public Object doHandle(Channel channel, DataChangeRequest request) {
request);
return null;
}
Set<String> dataInfoIds = request.getDataInfoIds().keySet();
LOGGER.info(
"[DataChangeRequest]dataCenter:{} data change:{}",
request.getDataCenter(),
request.getDataInfoIds().keySet());
multiClusterSlotManager.dataChangeNotify(
request.getDataCenter(), request.getDataInfoIds().keySet());
dataInfoIds.size());
multiClusterSlotManager.dataChangeNotify(request.getDataCenter(), dataInfoIds);
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.alipay.sofa.registry.server.data.multi.cluster.exchanger.RemoteDataNodeExchanger;
import com.alipay.sofa.registry.server.data.multi.cluster.executor.MultiClusterExecutorManager;
import com.alipay.sofa.registry.server.data.multi.cluster.loggers.Loggers;
import com.alipay.sofa.registry.server.data.multi.cluster.slot.MultiClusterSlotMetrics.SyncType;
import com.alipay.sofa.registry.server.data.multi.cluster.sync.info.FetchMultiSyncService;
import com.alipay.sofa.registry.server.data.slot.SlotChangeListenerManager;
import com.alipay.sofa.registry.server.data.slot.SlotDiffSyncer;
Expand All @@ -51,7 +52,6 @@
import com.alipay.sofa.registry.server.data.slot.SyncContinues;
import com.alipay.sofa.registry.server.data.slot.SyncLeaderTask;
import com.alipay.sofa.registry.server.data.timer.Metrics;
import com.alipay.sofa.registry.server.data.timer.Metrics.SyncType;
import com.alipay.sofa.registry.server.shared.remoting.ClientSideExchanger;
import com.alipay.sofa.registry.store.api.meta.MultiClusterSyncRepository;
import com.alipay.sofa.registry.task.KeyedTask;
Expand Down Expand Up @@ -897,7 +897,7 @@ private void syncRemoteDataIds(
MULTI_CLUSTER_SYNC_DIGEST_LOGGER);
state.syncDataIdTask =
multiClusterExecutorManager.getRemoteSyncDataIdExecutor().execute(slot.getId(), task);
Metrics.syncAccess(SyncType.SYNC_DELTA);
MultiClusterSlotMetrics.syncAccess(remoteDataCenter, SyncType.SYNC_DELTA);
return;
}

Expand Down Expand Up @@ -943,7 +943,7 @@ void syncRemote(
MULTI_CLUSTER_SYNC_DIGEST_LOGGER);
state.syncRemoteTask =
multiClusterExecutorManager.getRemoteSyncLeaderExecutor().execute(slot.getId(), task);
Metrics.syncAccess(SyncType.SYNC_ALL);
MultiClusterSlotMetrics.syncAccess(remoteDataCenter, SyncType.SYNC_ALL);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,29 @@ static void observeRemoteLeaderSyncingHistogram(String dataCenter, int slotId, l
.labels(dataCenter, String.valueOf(slotId))
.observe(millis / 1000d);
}

private static final Counter SYNC_COUNTER =
Counter.build()
.namespace("data")
.subsystem("access")
.name("sync_total")
.labelNames("remote", "type")
.help("sync data access num")
.register();

public static void syncAccess(String remote, SyncType syncType) {
if (syncType == SyncType.SYNC_ALL) {
SYNC_COUNTER.labels(remote, "ALL").inc();
} else if (syncType == SyncType.SYNC_DELTA) {
SYNC_COUNTER.labels(remote, "DELTA").inc();
} else {
throw new IllegalArgumentException("illegal sync type: " + syncType);
}
}

public enum SyncType {
SYNC_ALL,
SYNC_DELTA,
;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,4 @@ private Metrics() {}
.labelNames("dataCenter", "remote", "instanceId", "group")
.help("publisher dataID cache num")
.register();

private static final Counter SYNC_COUNTER =
Counter.build()
.namespace("data")
.subsystem("access")
.name("sync_total")
.labelNames("type")
.help("sync data access num")
.register();
static final Counter.Child SYNC_ALL = SYNC_COUNTER.labels("ALL");
static final Counter.Child SYNC_DELTA = SYNC_COUNTER.labels("DELTA");

public static void syncAccess(SyncType syncType) {
if (syncType == SyncType.SYNC_ALL) {
SYNC_ALL.inc();
} else if (syncType == SyncType.SYNC_DELTA) {
SYNC_DELTA.inc();
} else {
throw new IllegalArgumentException("illegal sync type: " + syncType);
}
}

public enum SyncType {
SYNC_ALL,
SYNC_DELTA,
;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,28 +124,25 @@ static final class Push {
.subsystem("push")
.name("push_delay")
.help("push delay")
.labelNames("cause", "status")
.labelNames("datacenter", "cause", "status")
.register();

private static final Histogram.Child SUB_OK =
PUSH_DELAY_HISTOGRAM.labels(PushType.Sub.name(), PushTrace.PushStatus.OK.name());
private static final Histogram.Child REG_OK =
PUSH_DELAY_HISTOGRAM.labels(PushType.Reg.name(), PushTrace.PushStatus.OK.name());

static void observePushDelayHistogram(
static void observePushDelayHistogram(String dataCenter,
PushType pushType, long millis, PushTrace.PushStatus status) {
// quick path
if (status == PushTrace.PushStatus.OK) {
if (pushType == PushType.Sub) {
SUB_OK.observe(millis);
PUSH_DELAY_HISTOGRAM.labels(dataCenter, PushType.Sub.name(), PushTrace.PushStatus.OK.name()).observe(millis);

return;
}
if (pushType == PushType.Reg) {
REG_OK.observe(millis);
PUSH_DELAY_HISTOGRAM.labels(dataCenter, PushType.Reg.name(), PushTrace.PushStatus.OK.name()).observe(millis);

return;
}
}
PUSH_DELAY_HISTOGRAM.labels(pushType.name(), status.name()).observe(millis);
PUSH_DELAY_HISTOGRAM.labels(dataCenter, pushType.name(), status.name()).observe(millis);
}

static final Counter PUSH_EMPTY_SKIP_COUNTER =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private void finish(
datumModifyPushSpanMillis = Math.max(datumPushedDelayList.get(0), datumVersionPushSpanMillis);
}

PushMetrics.Push.observePushDelayHistogram(
PushMetrics.Push.observePushDelayHistogram(dataCenter,
pushCause.pushType, datumModifyPushSpanMillis, status);
if (LOGGER.isInfoEnabled() || SLOW_LOGGER.isInfoEnabled()) {
final String msg =
Expand Down
10 changes: 10 additions & 0 deletions test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@
<testFailureIgnore>true</testFailureIgnore>
</configuration>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skipTests>true</skipTests>
</configuration>
</execution>
<execution>
<id>test-junit</id>
<phase>test</phase>
Expand Down