You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/07/28 11:05:46 UTC
[04/10] ignite git commit: Finalizing start/stop logic.
Finalizing start/stop logic.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b2c89728
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b2c89728
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b2c89728
Branch: refs/heads/ignite-3553
Commit: b2c897285549d4f0b7162894f5a66bdfcfe4145d
Parents: d0b4aa6
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Jul 27 16:05:27 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Jul 27 16:05:27 2016 +0300
----------------------------------------------------------------------
.../igfs/client/IgfsClientManager.java | 40 +++++++++++++++++---
1 file changed, 35 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b2c89728/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientManager.java
index 357d5d9..c393bb9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientManager.java
@@ -24,6 +24,7 @@ import org.apache.ignite.internal.GridTopic;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.managers.communication.GridIoPolicy;
import org.apache.ignite.internal.managers.communication.GridMessageListener;
+import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.processors.igfs.IgfsImpl;
import org.apache.ignite.internal.processors.igfs.IgfsManager;
@@ -38,6 +39,10 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
+import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
+import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
+import static org.apache.ignite.events.EventType.EVT_NODE_METRICS_UPDATED;
+
/**
* Manager to handle IGFS client closures.
*/
@@ -61,6 +66,9 @@ public class IgfsClientManager extends IgfsManager {
private final StripedCompositeReadWriteLock rwLock =
new StripedCompositeReadWriteLock(Runtime.getRuntime().availableProcessors() * 2);
+ /** Discovery listener. */
+ private final GridLocalEventListener discoLsnr = new DiscoveryListener();
+
/** IO message listener. */
private final MessageListener msgLsnr = new MessageListener();
@@ -79,26 +87,48 @@ public class IgfsClientManager extends IgfsManager {
@Override protected void start0() throws IgniteCheckedException {
ctx.io().addMessageListener(GridTopic.TOPIC_IGFS_CLI, msgLsnr);
- // TODO: Discovery listener.
+ ctx.event().addLocalEventListener(discoLsnr, EVT_NODE_FAILED, EVT_NODE_LEFT, EVT_NODE_METRICS_UPDATED);
}
/** {@inheritDoc} */
@Override protected void onKernalStart0() throws IgniteCheckedException {
- // TODO: Set ready flag.
+ rwLock.writeLock().lock();
+
+ try {
+ ready = true;
+
+ if (!pending.isEmpty()) {
+ // TODO: Start separate thread.
+ }
+ }
+ finally {
+ rwLock.writeLock().unlock();
+ }
}
/** {@inheritDoc} */
@Override protected void onKernalStop0(boolean cancel) {
+ ctx.event().removeLocalEventListener(discoLsnr);
+
ctx.io().removeMessageListener(GridTopic.TOPIC_IGFS_CLI, msgLsnr);
- // TODO: Discovery listener.
+ rwLock.writeLock().lock();
+
+ try {
+ stopping = true;
+ }
+ finally {
+ rwLock.writeLock().unlock();
+ }
- // TODO: Set stopping flag
+ // Stop pending worker (if any).
+ // TODO
}
/** {@inheritDoc} */
@Override protected void stop0(boolean cancel) {
- // TODO: Cleanup everything.
+ pending.clear();
+ outOps.clear();
}
/**