Package org.jboss.as.clustering

Examples of org.jboss.as.clustering.ClusterNode


        NonGloballyExclusiveClusterLockSupport testee = testeeSet.impl;
        LocalLockHandler handler = testee.getLocalHandler();
        RpcTarget target = testeeSet.target;

        List<ClusterNode> members = testee.getCurrentView();
        ClusterNode caller1 = members.get(0);
        assertFalse(node1.equals(caller1));

        ClusterNode caller2 = members.get(2);
        assertFalse(node1.equals(caller2));

        RemoteLockResponse rsp = target.remoteLock("test", caller1, 1000);

        verify(handler).lockFromCluster("test", caller1, 1000);
View Full Code Here


        TesteeSet<NonGloballyExclusiveClusterLockSupport> testeeSet = getTesteeSet(node1, 1, 3);
        NonGloballyExclusiveClusterLockSupport testee = testeeSet.impl;
        LocalLockHandler handler = testee.getLocalHandler();
        RpcTarget target = testeeSet.target;

        ClusterNode caller1 = testee.getCurrentView().get(0);
        ClusterNode caller2 = testee.getCurrentView().get(2);

        when(handler.getLockHolder("test")).thenReturn(caller1);

        RemoteLockResponse rsp = target.remoteLock("test", caller1, 1);
       
View Full Code Here

    // ------------------------------------------------------------------ Public

    @Override
    public void unlock(Serializable lockId) {
        ClusterNode myself = getLocalClusterNode();
        if (myself == null) {
            throw MESSAGES.invalidMethodCall("start()", "unlock()");
        }

        ClusterLockState lockState = getClusterLockState(lockId, false);

        if (lockState != null && myself.equals(lockState.getHolder())) {
            getLocalHandler().unlockFromCluster(lockId, myself);
            lockState.release();

            try {
                getGroupRpcDispatcher().callMethodOnCluster(getServiceHAName(), "releaseRemoteLock",
View Full Code Here

    // ------------------------------------------------------ ClusterLockManager

    @Override
    public void unlock(Serializable lockId) {
        ClusterNode myself = getLocalClusterNode();
        if (myself == null) {
            throw MESSAGES.invalidMethodCall("start()", "unlock()");
        }

        ClusterLockState category = getClusterLockState(lockId, false);

        if (category == null) {
            getLocalHandler().unlockFromCluster(lockId, myself);
        } else if (myself.equals(category.getHolder())) {
            category.invalidate();
            getLocalHandler().unlockFromCluster(lockId, myself);
            removeLockState(category);
        }
    }
View Full Code Here

        long left = timeout > 0 ? timeout : Long.MAX_VALUE;
        long start = System.currentTimeMillis();
        while (left > 0) {
            // Another node we lost to who should take precedence
            // over ourselves in competition for the lock
            ClusterNode superiorCompetitor = null;

            // Only continue if category is unlocked
            if (category.state.compareAndSet(ClusterLockState.State.UNLOCKED, ClusterLockState.State.REMOTE_LOCKING)) {
                // Category state is now REMOTE_LOCKING, so other nodes will fail
                // in attempts to acquire on this node unless the caller is "superior"
View Full Code Here

    }

    @Override
    public void register(final String service, Listener listener) {
        this.listeners.put(service, listener);
        final ClusterNode node = this.notifier.getClusterNode();
        Operation<Set<ClusterNode>> operation = new Operation<Set<ClusterNode>>() {
            @Override
            public Set<ClusterNode> invoke(Cache<String, Map<ClusterNode, Void>> cache) {
                Map<ClusterNode, Void> map = cache.putIfAbsent(service, null);
                map.put(node, null);
View Full Code Here

        listener.serviceProvidersChanged(nodes, false);
    }

    @Override
    public void unregister(final String service) {
        final ClusterNode node = this.notifier.getClusterNode();
        Operation<Void> operation = new Operation<Void>() {
            @Override
            public Void invoke(Cache<String, Map<ClusterNode, Void>> cache) {
                cache.get(service).remove(node);
                return null;
View Full Code Here

            this.stopOldMaster();
        }
    }

    private boolean elected(Set<ClusterNode> candidates) {
        ClusterNode elected = this.election(candidates);
        SingletonLogger.ROOT_LOGGER.elected(elected.getName(), this.singletonServiceName.getCanonicalName());
        return (elected != null) ? elected.equals(this.dispatcher.getClusterNode()) : false;
    }
View Full Code Here

         * Record interest in obtaining the lock. If the lock is unheld and <code>registrant</code> was the last holder of the
         * lock, then <code>registrant</code> will be made holder of the lock.
         * @return a LockState with a lock count one higher than this one and with the current thread as latestRegistrant
         */
        LockState register(ClusterNode registrant) {
            ClusterNode newHolder = (lockHolder == null && lastHolder == registrant) ? registrant : lockHolder;
            ClusterNode newLast = newHolder == null ? lastHolder : null;
            return new LockState(localLockCount + 1, newHolder, newLast, Thread.currentThread(), invalid);
        }
View Full Code Here

        long left = timeout > 0 ? timeout : Long.MAX_VALUE;
        long start = System.currentTimeMillis();
        while (left > 0) {
            // Another node we lost to who should take precedence
            // over ourself in competition for the lock
            ClusterNode superiorCompetitor = null;

            // Only continue if category is unlocked
            if (category.state.compareAndSet(ClusterLockState.State.UNLOCKED, ClusterLockState.State.REMOTE_LOCKING)) {
                // Category state is now REMOTE_LOCKING, so other nodes will fail
                // in attempts to acquire on this node unless the caller is "superior"
View Full Code Here

TOP

Related Classes of org.jboss.as.clustering.ClusterNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.