Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f99016f
commit 7cd25ab
Showing
12 changed files
with
680 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
hazelcast/src/main/java/com/hazelcast/internal/nearcache/impl/CompositeRemoteCallHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) 2008-2022, Hazelcast, Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hazelcast.internal.nearcache.impl; | ||
|
||
import com.hazelcast.internal.serialization.Data; | ||
import com.hazelcast.spi.impl.operationservice.Operation; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class CompositeRemoteCallHook<K, V> implements RemoteCallHook<K, V> { | ||
|
||
private final List<RemoteCallHook> hooks = new ArrayList<>(); | ||
|
||
public void add(RemoteCallHook newHook) { | ||
hooks.add(newHook); | ||
} | ||
|
||
@Override | ||
public void beforeRemoteCall(K key, Data keyData, | ||
@Nullable V value, @Nullable Data valueData) { | ||
for (int i = 0; i < hooks.size(); i++) { | ||
hooks.get(i).beforeRemoteCall(key, keyData, value, valueData); | ||
} | ||
} | ||
|
||
@Override | ||
public void onRemoteCallSuccess(@Nullable Operation remoteCall) { | ||
for (int i = 0; i < hooks.size(); i++) { | ||
hooks.get(i).onRemoteCallSuccess(remoteCall); | ||
} | ||
} | ||
|
||
@Override | ||
public void onRemoteCallFailure() { | ||
for (int i = 0; i < hooks.size(); i++) { | ||
hooks.get(i).onRemoteCallFailure(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
hazelcast/src/main/java/com/hazelcast/map/impl/MapOperationStatsUpdater.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (c) 2008-2022, Hazelcast, Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hazelcast.map.impl; | ||
|
||
import com.hazelcast.internal.monitor.impl.LocalMapStatsImpl; | ||
import com.hazelcast.internal.util.Timer; | ||
import com.hazelcast.map.impl.operation.BasePutOperation; | ||
import com.hazelcast.map.impl.operation.BaseRemoveOperation; | ||
import com.hazelcast.map.impl.operation.GetOperation; | ||
import com.hazelcast.map.impl.operation.SetOperation; | ||
import com.hazelcast.map.impl.tx.TxnDeleteOperation; | ||
import com.hazelcast.map.impl.tx.TxnSetOperation; | ||
import com.hazelcast.spi.impl.operationservice.Operation; | ||
|
||
/** | ||
* Helper to update map operation stats on caller side. | ||
*/ | ||
public final class MapOperationStatsUpdater { | ||
|
||
private MapOperationStatsUpdater() { | ||
} | ||
|
||
/** | ||
* Updates stats upon operation-call | ||
* on {@link com.hazelcast.map.IMap} | ||
*/ | ||
public static void incrementOperationStats(Operation operation, | ||
LocalMapStatsImpl localMapStats, | ||
long startTimeNanos) { | ||
|
||
long durationNanos = Timer.nanosElapsed(startTimeNanos); | ||
|
||
if (operation instanceof SetOperation) { | ||
localMapStats.incrementSetLatencyNanos(durationNanos); | ||
return; | ||
} | ||
|
||
if (operation instanceof BasePutOperation) { | ||
localMapStats.incrementPutLatencyNanos(durationNanos); | ||
return; | ||
} | ||
|
||
if (operation instanceof BaseRemoveOperation) { | ||
localMapStats.incrementRemoveLatencyNanos(durationNanos); | ||
return; | ||
} | ||
|
||
if (operation instanceof GetOperation) { | ||
localMapStats.incrementGetLatencyNanos(durationNanos); | ||
return; | ||
} | ||
} | ||
|
||
/** | ||
* Updates stats upon operation-call on {@link | ||
* com.hazelcast.transaction.TransactionalMap} | ||
*/ | ||
public static void incrementTxnOperationStats(Operation operation, | ||
LocalMapStatsImpl localMapStats, | ||
long startTimeNanos) { | ||
|
||
long durationNanos = Timer.nanosElapsed(startTimeNanos); | ||
|
||
if (operation instanceof TxnSetOperation) { | ||
localMapStats.incrementSetLatencyNanos(durationNanos); | ||
return; | ||
} | ||
|
||
if (operation instanceof TxnDeleteOperation) { | ||
localMapStats.incrementRemoveLatencyNanos(durationNanos); | ||
return; | ||
} | ||
|
||
if (operation instanceof GetOperation) { | ||
localMapStats.incrementGetLatencyNanos(durationNanos); | ||
return; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.