public CoreCmd(Gondola gondola, Cluster cluster, CoreMember cmember) { this.gondola = gondola; this.cluster = cluster; this.cmember = cmember; createdCount.incrementAndGet(); stats = gondola.getStats(); buffer = new byte[maxCommandSize]; reset(); }
public CoreCmd(Gondola gondola, Shard shard, CoreMember cmember) { this.gondola = gondola; this.shard = shard; this.cmember = cmember; createdCount.incrementAndGet(); stats = gondola.getStats(); buffer = new byte[maxCommandSize]; reset(); }
/** * Adds message to the incoming queue. Does not block. Called by connection objects after receiving a message. */ public void addIncoming(Message message) throws InterruptedException { message.acquire(); if (!incomingQueue.offer(message)) { gondola.getStats().incomingQueueFull(); incomingQueue.put(message); } lock.lock(); try { workAvailable.signal(); } finally { lock.unlock(); } }
/** * Adds message to the incoming queue. Does not block. * Called by connection objects after receiving a message. */ public void addIncoming(Message message) throws InterruptedException { message.acquire(); if (!incomingQueue.offer(message)) { gondola.getStats().incomingQueueFull(); incomingQueue.put(message); } lock.lock(); try { workAvailable.signal(); } finally { lock.unlock(); } }
Cluster(Gondola gondola, String clusterId) throws Exception { this.gondola = gondola; this.clusterId = clusterId; config = gondola.getConfig(); stats = gondola.getStats(); List<Config.ConfigMember> configMembers = config.getMembersInCluster(clusterId); List<Integer> peerIds = configMembers.stream() .filter(cm -> !cm.hostId.equals(gondola.getHostId())) .map(cm -> cm.memberId).collect(Collectors.toList()); // First create the local member, because it's needed when creating the remote members. for (int i = 0; i < configMembers.size(); i++) { Config.ConfigMember cm = configMembers.get(i); if (gondola.getHostId().equals(cm.hostId)) { // Local member boolean isPrimary = i == 0; cmember = new CoreMember(gondola, this, cm.memberId, peerIds, isPrimary); localMember = new Member(gondola, cmember, null); members.add(localMember); break; } } if (cmember == null) { throw new IllegalStateException(String.format("Host id %s not found in %d", config.getIdentifier())); } // Create list of peers for (Peer p : cmember.peers) { members.add(new Member(gondola, cmember, p)); } }
public Shard(Gondola gondola, String shardId) throws GondolaException { this.gondola = gondola; this.shardId = shardId; config = gondola.getConfig(); stats = gondola.getStats(); List<Config.ConfigMember> configMembers = config.getMembersInShard(shardId); List<Integer> peerIds = configMembers.stream() .filter(cm -> !cm.hostId.equals(gondola.getHostId())) .map(cm -> cm.memberId).collect(Collectors.toList()); // First create the local member, because it's needed when creating the remote members. for (int i = 0; i < configMembers.size(); i++) { Config.ConfigMember cm = configMembers.get(i); if (gondola.getHostId().equals(cm.hostId)) { // Local member boolean isPrimary = i == 0; cmember = new CoreMember(gondola, this, cm.memberId, peerIds, isPrimary); localMember = new Member(gondola, cmember, null); members.add(localMember); break; } } if (cmember == null) { throw new IllegalStateException(String.format("Host id %s not found in %d", config.getIdentifier())); } // Create list of peers for (Peer p : cmember.peers.values()) { members.add(new Member(gondola, cmember, p)); } }
@GET @Path("/gondolaStatus") public Map getGondolaStatus() throws InterruptedException { RoutingFilter routingFilter = GondolaApplication.getRoutingFilter(); Gondola gondola = routingFilter.getGondola(); ChangeLogProcessor changeLogProcessor = GondolaApplication.getRoutingFilter().getChangeLogProcessor(); Map<Object, Object> map = new LinkedHashMap<>(); map.put("hostId", gondola.getHostId()); map.put("gondolaStatus", getGondolaStatus(gondola, changeLogProcessor)); map.put("routingTable", routingFilter.getRoutingTable()); map.put("bucketTable", getBucketMapStatus(routingFilter.getBucketManager())); map.put("lock", getLockManagerStatus(routingFilter.getLockManager())); map.put("shardManager", getShardManagerStatus()); map.put("numActiveRequests", routingFilter.getBucketRequestCounters().values().stream().map(AtomicInteger::get) .reduce((i1, i2) -> i1 + i2).orElse(0)); map.put("config", getConfigInfo(gondola)); map.put("stats", gondola.getStats()); map.put("pid", gondola.getConfig().getAttributesForHost(gondola.getHostId()).get("hostname") + ":" + gondola.getProcessId()); map.put("timers", timerMap()); map.put("meters", GondolaApplication.MyMetricsServletContextListener.METRIC_REGISTRY.getMeters()); return map; }
CommitQueue(Gondola gondola, CoreMember cmember) throws GondolaException { this.gondola = gondola; this.cmember = cmember; this.storage = gondola.getStorage(); this.pool = gondola.getMessagePool(); this.savedIndex = null; //savedIndex; this.matchIndices = null; //matchIndices; gondola.getConfig().registerForUpdates(configListener); stats = gondola.getStats(); }
Stats stats = gondola.getStats(); logger.info( String.format("[%s-%d] %s%s %spid=%s wait=%dms cmdQ=%d waitQ=%d in=%d"
CommitQueue(Gondola gondola, CoreMember cmember) throws Exception { this.gondola = gondola; this.cmember = cmember; this.storage = gondola.getStorage(); this.pool = gondola.getMessagePool(); this.savedIndex = null;//savedIndex; this.matchIndices = null;//matchIndices; gondola.getConfig().registerForUpdates(this); stats = gondola.getStats(); }
gondola.getStats().sentMessage(message.size); lastSentTs = clock.now(); } catch (InterruptedException e) {
Stats stats = gondola.getStats(); logger.info(String.format("[%s-%d] %s pid=%s wait=%dms cmdQ=%d waitQ=%d in=%d|%.1f/s out=%.1f/s lat=%.3fms/%.3fms", gondola.getHostId(), memberId, role, gondola.getProcessId(), waitMs, commandQueue.size(), waitQueue.size(),
gondola.getHostId(), cmember.memberId, peerId, message.size + excess); gondola.getStats().incomingMessage(message.size + excess);
gondola.getStats().sentMessage(message.size); lastSentTs = clock.now(); } catch (InterruptedException | EOFException e) {
SaveQueue(Gondola gondola, CoreMember cmember) throws GondolaException { this.gondola = gondola; this.cmember = cmember; gondola.getConfig().registerForUpdates(configListener); storage = gondola.getStorage(); stats = gondola.getStats(); numWorkers = gondola.getConfig().getInt("storage.save_queue_workers"); String address = storage.getAddress(cmember.memberId); if (address != null && !address.equals(gondola.getNetwork().getAddress()) && gondola.getNetwork().isActive(address)) { throw new IllegalStateException(String.format("[%s-%s] Process %s at address %s is currently using storage", gondola.getHostId(), cmember.memberId, gondola.getProcessId(), address)); } storage.setAddress(cmember.memberId, gondola.getNetwork().getAddress()); storage.setPid(cmember.memberId, gondola.getProcessId()); initSavedIndex(); }
SaveQueue(Gondola gondola, CoreMember cmember) throws Exception { this.gondola = gondola; this.cmember = cmember; gondola.getConfig().registerForUpdates(this); storage = gondola.getStorage(); stats = gondola.getStats(); numWorkers = gondola.getConfig().getInt("storage.save_queue_workers"); String address = storage.getAddress(cmember.memberId); if (address != null && gondola.getNetwork().isActive(address)) { throw new IllegalStateException(String.format("[%s-%s] Process %s at address %s is currently using storage", gondola.getHostId(), cmember.memberId, gondola.getProcessId(), address)); } storage.setAddress(cmember.memberId, gondola.getNetwork().getAddress()); storage.setPid(cmember.memberId, gondola.getProcessId()); initSavedIndex(); }
gondola.getHostId(), cmember.memberId, peerId, message.size + excess); gondola.getStats().incomingMessage(message.size + excess);