You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by nt...@apache.org on 2016/04/13 14:17:53 UTC
ignite git commit: IGNITE-2004 Added event probes.
Repository: ignite
Updated Branches:
refs/heads/ignite-2004 6b90d19d7 -> 2d55a9e0c
IGNITE-2004 Added event probes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2d55a9e0
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2d55a9e0
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2d55a9e0
Branch: refs/heads/ignite-2004
Commit: 2d55a9e0cf752af269727b6ebe886a7a070457e5
Parents: 6b90d19
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Wed Apr 13 15:17:49 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Wed Apr 13 15:17:49 2016 +0300
----------------------------------------------------------------------
.../cache/CacheEntryEventAsyncProbe.java | 61 ++++++++++++++++++++
.../yardstick/cache/CacheEntryEventProbe.java | 33 ++++++-----
2 files changed, 81 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2d55a9e0/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/CacheEntryEventAsyncProbe.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/CacheEntryEventAsyncProbe.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/CacheEntryEventAsyncProbe.java
new file mode 100644
index 0000000..0ea66d4
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/CacheEntryEventAsyncProbe.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.ignite.yardstick.cache;
+
+import java.util.concurrent.atomic.AtomicLong;
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.CacheEntryUpdatedListener;
+import org.apache.ignite.lang.IgniteAsyncCallback;
+
+/**
+ * Probe which calculate continuous query events.
+ */
+public class CacheEntryEventAsyncProbe extends CacheEntryEventProbe {
+ /** */
+ @Override protected CacheEntryUpdatedListener<Integer, Integer> localListener(AtomicLong cntr) {
+ return new CacheEntryEventListener(cntr);
+ }
+
+ /**
+ *
+ */
+ @IgniteAsyncCallback
+ private static final class CacheEntryEventListener implements CacheEntryUpdatedListener<Integer, Integer> {
+ /** */
+ private AtomicLong cnt;
+
+ /**
+ * @param cnt Counter.
+ */
+ public CacheEntryEventListener(AtomicLong cnt) {
+ this.cnt = cnt;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> events)
+ throws CacheEntryListenerException {
+ int size = 0;
+
+ for (CacheEntryEvent<? extends Integer, ? extends Integer> e : events)
+ ++size;
+
+ cnt.addAndGet(size);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2d55a9e0/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/CacheEntryEventProbe.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/CacheEntryEventProbe.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/CacheEntryEventProbe.java
index e42479a..a25f975 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/CacheEntryEventProbe.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/CacheEntryEventProbe.java
@@ -45,9 +45,6 @@ public class CacheEntryEventProbe implements BenchmarkProbe {
/** */
private BenchmarkConfiguration cfg;
- /** Counter. */
- private AtomicLong cnt = new AtomicLong(0);
-
/** Collected points. */
private Collection<BenchmarkProbePoint> collected = new ArrayList<>();
@@ -67,17 +64,9 @@ public class CacheEntryEventProbe implements BenchmarkProbe {
if (drv0.cache() != null) {
ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>();
- qry.setLocalListener(new CacheEntryUpdatedListener<Integer, Integer>() {
- @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>>
- events) throws CacheEntryListenerException {
- int size = 0;
-
- for (CacheEntryEvent<? extends Integer, ? extends Integer> e : events)
- ++size;
+ final AtomicLong cnt = new AtomicLong();
- cnt.addAndGet(size);
- }
- });
+ qry.setLocalListener(localListener(cnt));
qryCur = drv0.cache().query(qry);
@@ -113,6 +102,24 @@ public class CacheEntryEventProbe implements BenchmarkProbe {
+ " probe. Probably, the driver doesn't provide \"cache()\" method.");
}
+ /**
+ * @param cntr Received event counter.
+ * @return Local listener.
+ */
+ protected CacheEntryUpdatedListener<Integer, Integer> localListener(final AtomicLong cntr) {
+ return new CacheEntryUpdatedListener<Integer, Integer>() {
+ @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> events)
+ throws CacheEntryListenerException {
+ int size = 0;
+
+ for (CacheEntryEvent<? extends Integer, ? extends Integer> e : events)
+ ++size;
+
+ cntr.addAndGet(size);
+ }
+ };
+ }
+
/** {@inheritDoc} */
@Override public void stop() throws Exception {
if (qryCur != null) {