Search in sources :

Example 6 with SlaveContext

use of org.neo4j.com.SlaveContext in project graphdb by neo4j-attic.

the class MasterImpl method getOngoingTransactions.

// =====================================================================
// Just some methods which aren't really used when running a HA cluster,
// but exposed so that other tools can reach that information.
// =====================================================================
public Map<Integer, Collection<SlaveContext>> getOngoingTransactions() {
    Map<Integer, Collection<SlaveContext>> result = new HashMap<Integer, Collection<SlaveContext>>();
    for (SlaveContext context : transactions.keySet()) {
        Collection<SlaveContext> txs = result.get(context.machineId());
        if (txs == null) {
            txs = new ArrayList<SlaveContext>();
            result.put(context.machineId(), txs);
        }
        txs.add(context);
    }
    return result;
}
Also used : SlaveContext(org.neo4j.com.SlaveContext) HashMap(java.util.HashMap) Collection(java.util.Collection)

Example 7 with SlaveContext

use of org.neo4j.com.SlaveContext in project graphdb by neo4j-attic.

the class MasterServer method getSlaveInformation.

public Map<Integer, Collection<SlaveContext>> getSlaveInformation() {
    // Which slaves are connected a.t.m?
    Set<Integer> machineIds = new HashSet<Integer>();
    Map<Channel, SlaveContext> channels = getConnectedSlaveChannels();
    synchronized (channels) {
        for (SlaveContext context : channels.values()) {
            machineIds.add(context.machineId());
        }
    }
    // Insert missing slaves into the map so that all connected slave
    // are in the returned map
    Map<Integer, Collection<SlaveContext>> ongoingTransactions = ((MasterImpl) getMaster()).getOngoingTransactions();
    for (Integer machineId : machineIds) {
        if (!ongoingTransactions.containsKey(machineId)) {
            ongoingTransactions.put(machineId, Collections.<SlaveContext>emptyList());
        }
    }
    return new TreeMap<Integer, Collection<SlaveContext>>(ongoingTransactions);
}
Also used : SlaveContext(org.neo4j.com.SlaveContext) Channel(org.jboss.netty.channel.Channel) Collection(java.util.Collection) TreeMap(java.util.TreeMap) HashSet(java.util.HashSet)

Aggregations

SlaveContext (org.neo4j.com.SlaveContext)7 Pair (org.neo4j.helpers.Pair)4 XaDataSource (org.neo4j.kernel.impl.transaction.xaframework.XaDataSource)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 XaDataSourceManager (org.neo4j.kernel.impl.transaction.XaDataSourceManager)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 TreeMap (java.util.TreeMap)1 Channel (org.jboss.netty.channel.Channel)1 ToFileStoreWriter (org.neo4j.com.ToFileStoreWriter)1 AbstractGraphDatabase (org.neo4j.kernel.AbstractGraphDatabase)1 NeoStoreXaDataSource (org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource)1