src/main/java/com/findupon/cluster/master/MasterNodeAgency.java
/**
	 * If the node is still working on other sources, keep it in the working pool and update its description.
	 * Otherwise, transition its state and move to the wait pool.
	 */
If the node is still working on other sources, keep it in the working pool and update its description.
Otherwise, transition its state and move to the wait pool.
If the node is still working on other sources keep it in the working pool and update its description . Otherwise transition its state and move to the wait pool .
void waitTransition(WorkerNode node, ClusterTransmission transmission) {
		synchronized(mutex) {
			boolean stillWorking = !getSentWorkRequestsSnapshotForNode(node).isEmpty();
			if(stillWorking) {
				logger.trace("[Node {}] - Still working, updating work description for wait transition...", node.getId());
			} else {
				logger.trace("[Node {}] - Transitioning to waiting...", node.getId());
			}
			if(waitingNodes.contains(node)) {
				logger.error("[Node {}] - Already in the waiting pool, transition to waiting fails!", node.getId(),
						new UnsupportedOperationException("Wait transition failure"));
			} else {
				if(stillWorking) {
					if(transmission.getDataSource() != null) {
						List<String> workingSources = new ArrayList<>(Arrays.asList(node.getWorkDescription().split(" ~ ")));
						workingSources.remove(transmission.getDataSource().getUrl());
						node.setWorkDescription(workingSources.stream().collect(Collectors.joining(" ~ ")));
					}
				} else {
					node.setIsWorking(false);
					node.setWorkDescription(null);
					workingNodes.remove(node);
					waitingNodes.add(node);
				}
				workerNodeRepo.saveAndFlush(node);
				if(!stillWorking) {
					logger.debug("[Node {}] - Transitioned to waiting", node.getId());
				}
			}
		}
		logger.trace("[Node {}] - Waiting transition lock released", node.getId());
	}
void waitTransition ( WorkerNode node , ClusterTransmission transmission ) { synchronized ( mutex ) { boolean stillWorking = ! getSentWorkRequestsSnapshotForNode ( node ) . isEmpty ( ) ; if ( stillWorking ) { logger . trace ( "[Node {}] - Still working, updating work description for wait transition..." , node . getId ( ) ) ; } else { logger . trace ( "[Node {}] - Transitioning to waiting..." , node . getId ( ) ) ; } if ( waitingNodes . contains ( node ) ) { logger . error ( "[Node {}] - Already in the waiting pool, transition to waiting fails!" , node . getId ( ) , new UnsupportedOperationException ( "Wait transition failure" ) ) ; } else { if ( stillWorking ) { if ( transmission . getDataSource ( ) != null ) { List < String > workingSources = new ArrayList < > ( Arrays . asList ( node . getWorkDescription ( ) . split ( " ~ " ) ) ) ; workingSources . remove ( transmission . getDataSource ( ) . getUrl ( ) ) ; node . setWorkDescription ( workingSources . stream ( ) . collect ( Collectors . joining ( " ~ " ) ) ) ; } } else { node . setIsWorking ( false ) ; node . setWorkDescription ( null ) ; workingNodes . remove ( node ) ; waitingNodes . add ( node ) ; } workerNodeRepo . saveAndFlush ( node ) ; if ( ! stillWorking ) { logger . debug ( "[Node {}] - Transitioned to waiting" , node . getId ( ) ) ; } } } logger . trace ( "[Node {}] - Waiting transition lock released" , node . getId ( ) ) ; }
If the node is still working on other sources, keep it in the working pool and update its description.
If the node is still working on other sources keep it in the working pool and update its description .