/** {@inheritDoc} */ @Override public Collection<ClusterNode> nodes() { if (ctx.discovery().topologyVersion() != state.lastTopVer) reset(); ClusterNode node = state.node; return node == null ? Collections.<ClusterNode>emptyList() : Collections.singletonList(node); }
/** {@inheritDoc} */ @Override public ClusterGroup forPredicate(IgnitePredicate<ClusterNode> p) { A.notNull(p, "p"); guard(); try { if (p != null) ctx.resource().injectGeneric(p); return new ClusterGroupAdapter(ctx, this.subjId, new GroupPredicate(this, p)); } catch (IgniteCheckedException e) { throw U.convertException(e); } finally { unguard(); } }
/** * Resets node. */ private synchronized void reset() { guard(); try { long lastTopVer = ctx.discovery().topologyVersion(); ClusterNode node = isOldest ? U.oldest(super.nodes(), null) : U.youngest(super.nodes(), null); IgnitePredicate<ClusterNode> p = F.nodeForNodes(node); state = new AgeClusterGroupState(node, p, lastTopVer); } finally { unguard(); } }
/** {@inheritDoc} */ @Override public ClusterGroup forYoungest() { return new AgeClusterGroup(this, false); }
/** {@inheritDoc} */ @Override public Collection<ClusterNode> nodes() { if (ctx.discovery().topologyVersion() != state.lastTopVer) reset(); ClusterNode node = state.node; return node == null ? Collections.<ClusterNode>emptyList() : Collections.singletonList(node); }
/** * @param parent Parent cluster group. * @param isOldest Oldest flag. */ private AgeClusterGroup(ClusterGroupAdapter parent, boolean isOldest) { super(parent.ctx, parent.subjId, parent.p, parent.ids); this.isOldest = isOldest; reset(); }
/** {@inheritDoc} */ @Override public IgnitePredicate<ClusterNode> predicate() { if (ctx.discovery().topologyVersion() != state.lastTopVer) reset(); return state.p; }
/** {@inheritDoc} */ @Override public ClusterGroup forOldest() { return new AgeClusterGroup(this, true); }
/** {@inheritDoc} */ @Override public ClusterNode node() { if (ctx.discovery().topologyVersion() != state.lastTopVer) reset(); return state.node; }
/** * Reconstructs object on unmarshalling. * * @return Reconstructed object. * @throws ObjectStreamException Thrown in case of unmarshalling error. */ @Override protected Object readResolve() throws ObjectStreamException { ClusterGroupAdapter parent = (ClusterGroupAdapter)super.readResolve(); return new AgeClusterGroup(parent, isOldest); } }
/** * Resets node. */ private synchronized void reset() { guard(); try { long lastTopVer = ctx.discovery().topologyVersion(); ClusterNode node = isOldest ? U.oldest(super.nodes(), null) : U.youngest(super.nodes(), null); IgnitePredicate<ClusterNode> p = F.nodeForNodes(node); state = new AgeClusterGroupState(node, p, lastTopVer); } finally { unguard(); } }
/** {@inheritDoc} */ @Override public ClusterGroup forPredicate(IgnitePredicate<ClusterNode> p) { A.notNull(p, "p"); guard(); try { if (p != null) ctx.resource().injectGeneric(p); return new ClusterGroupAdapter(ctx, this.subjId, new GroupPredicate(this, p)); } catch (IgniteCheckedException e) { throw U.convertException(e); } finally { unguard(); } }
/** {@inheritDoc} */ @Override public ClusterGroup forOldest() { return new AgeClusterGroup(this, true); }
/** {@inheritDoc} */ @Override public ClusterGroup forYoungest() { return new AgeClusterGroup(this, false); }
/** {@inheritDoc} */ @Override public IgnitePredicate<ClusterNode> predicate() { if (ctx.discovery().topologyVersion() != state.lastTopVer) reset(); return state.p; }
/** * @param parent Parent cluster group. * @param isOldest Oldest flag. */ private AgeClusterGroup(ClusterGroupAdapter parent, boolean isOldest) { super(parent.ctx, parent.subjId, parent.p, parent.ids); this.isOldest = isOldest; reset(); }
/** * Reconstructs object on unmarshalling. * * @return Reconstructed object. * @throws ObjectStreamException Thrown in case of unmarshalling error. */ @Override protected Object readResolve() throws ObjectStreamException { ClusterGroupAdapter parent = (ClusterGroupAdapter)super.readResolve(); return new AgeClusterGroup(parent, isOldest); } }
/** {@inheritDoc} */ @Override public ClusterNode node() { if (ctx.discovery().topologyVersion() != state.lastTopVer) reset(); return state.node; }