Search in sources :

Example 6 with ManagedOperation

use of org.jgroups.annotations.ManagedOperation in project JGroups by belaban.

the class UNICAST3 method triggerXmit.

@ManagedOperation(description = "Triggers the retransmission task")
public void triggerXmit() {
    SeqnoList missing;
    for (Map.Entry<Address, ReceiverEntry> entry : recv_table.entrySet()) {
        // target to send retransmit requests to
        Address target = entry.getKey();
        ReceiverEntry val = entry.getValue();
        Table<Message> win = val != null ? val.msgs : null;
        // receiver: send ack for received messages if needed
        if (// sendAck() resets send_ack to false
        win != null && val.sendAck())
            sendAck(target, win.getHighestDeliverable(), val.connId());
        // receiver: retransmit missing messages (getNumMissing() is fast)
        if (win != null && win.getNumMissing() > 0 && (missing = win.getMissing(max_xmit_req_size)) != null) {
            long highest = missing.getLast();
            Long prev_seqno = xmit_task_map.get(target);
            if (prev_seqno == null)
                // no retransmission
                xmit_task_map.put(target, highest);
            else {
                // we only retransmit the 'previous batch'
                missing.removeHigherThan(prev_seqno);
                if (highest > prev_seqno)
                    xmit_task_map.put(target, highest);
                if (!missing.isEmpty())
                    retransmit(missing, target);
            }
        } else if (!xmit_task_map.isEmpty())
            // no current gaps for target
            xmit_task_map.remove(target);
    }
    // sender: only send the *highest sent* message if HA < HS and HA/HS didn't change from the prev run
    for (SenderEntry val : send_table.values()) {
        Table<Message> win = val != null ? val.msgs : null;
        if (win != null) {
            // highest delivered == highest ack (sender win)
            long highest_acked = win.getHighestDelivered();
            // we use table as a *sender* win, so it's highest *sent*...
            long highest_sent = win.getHighestReceived();
            if (highest_acked < highest_sent && val.watermark[0] == highest_acked && val.watermark[1] == highest_sent) {
                // highest acked and sent hasn't moved up - let's resend the HS
                Message highest_sent_msg = win.get(highest_sent);
                if (highest_sent_msg != null)
                    retransmit(highest_sent_msg);
            } else
                val.watermark(highest_acked, highest_sent);
        }
    }
    // close idle connections
    if (conn_expiry_timeout > 0)
        closeIdleConnections();
    if (conn_close_timeout > 0)
        removeExpiredConnections();
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) ConcurrentMap(java.util.concurrent.ConcurrentMap) ManagedOperation(org.jgroups.annotations.ManagedOperation)

Example 7 with ManagedOperation

use of org.jgroups.annotations.ManagedOperation in project JGroups by belaban.

the class MemcachedConnector method start.

@ManagedOperation
public void start() throws IOException, MalformedObjectNameException, MBeanRegistrationException {
    srv_sock = new ServerSocket(port, 50, bind_addr);
    if (thread_pool == null) {
        thread_pool = new ThreadPoolExecutor(core_threads, max_threads, idle_time, TimeUnit.MILLISECONDS, new SynchronousQueue<>(), new ThreadPoolExecutor.CallerRunsPolicy());
    // thread_pool=new DirectExecutor();
    }
    if (thread == null || !thread.isAlive()) {
        thread = new Thread(this, "Acceptor");
        thread.start();
    }
    start_time = System.currentTimeMillis();
}
Also used : ServerSocket(java.net.ServerSocket) ManagedOperation(org.jgroups.annotations.ManagedOperation)

Example 8 with ManagedOperation

use of org.jgroups.annotations.ManagedOperation in project JGroups by belaban.

the class PartitionedHashMap method stop.

@ManagedOperation
public void stop() {
    if (l1_cache != null)
        l1_cache.stop();
    if (migrate_data) {
        List<Address> members_without_me = new ArrayList<>(view.getMembers());
        members_without_me.remove(local_addr);
        for (Map.Entry<K, Cache.Value<V>> entry : l2_cache.entrySet()) {
            K key = entry.getKey();
            Address node = hash_function.hash(key, members_without_me);
            if (!node.equals(local_addr)) {
                Cache.Value<V> val = entry.getValue();
                sendPut(node, key, val.getValue(), val.getTimeout(), true);
                if (log.isTraceEnabled())
                    log.trace("migrated " + key + " from " + local_addr + " to " + node);
            }
        }
    }
    l2_cache.stop();
    disp.stop();
    ch.close();
}
Also used : Address(org.jgroups.Address) ManagedOperation(org.jgroups.annotations.ManagedOperation)

Example 9 with ManagedOperation

use of org.jgroups.annotations.ManagedOperation in project JGroups by belaban.

the class PartitionedHashMap method start.

@ManagedOperation
public void start() throws Exception {
    hash_function = new ConsistentHashFunction<>();
    addMembershipListener((MembershipListener) hash_function);
    ch = new JChannel(props);
    Marshaller m = new CustomMarshaller();
    disp = new RpcDispatcher(ch, this).setMarshaller(m).setMethodLookup(methods::get).setMembershipListener(this);
    ch.connect(cluster_name);
    local_addr = ch.getAddress();
    view = ch.getView();
}
Also used : JChannel(org.jgroups.JChannel) ManagedOperation(org.jgroups.annotations.ManagedOperation)

Example 10 with ManagedOperation

use of org.jgroups.annotations.ManagedOperation in project JGroups by belaban.

the class TCPGOSSIP method addInitialHost.

@ManagedOperation
public void addInitialHost(String hostname, int port) {
    // if there is such a stub already, remove and destroy it
    removeInitialHost(hostname, port);
    // now re-add it
    InetSocketAddress isa = new InetSocketAddress(hostname, port);
    initial_hosts.add(isa);
    stubManager.createAndRegisterStub(null, new IpAddress(isa.getAddress(), isa.getPort()));
    // tries to connect all unconnected stubs
    stubManager.connectStubs();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) IpAddress(org.jgroups.stack.IpAddress) ManagedOperation(org.jgroups.annotations.ManagedOperation)

Aggregations

ManagedOperation (org.jgroups.annotations.ManagedOperation)15 Address (org.jgroups.Address)5 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 IpAddress (org.jgroups.stack.IpAddress)3 InetAddress (java.net.InetAddress)2 InetSocketAddress (java.net.InetSocketAddress)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 JChannel (org.jgroups.JChannel)2 PhysicalAddress (org.jgroups.PhysicalAddress)2 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 Method (java.lang.reflect.Method)1 ServerSocket (java.net.ServerSocket)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 View (org.jgroups.View)1 ManagedAttribute (org.jgroups.annotations.ManagedAttribute)1 Property (org.jgroups.annotations.Property)1