All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.hycube.dht.HyCubeDHTBackgroundProcess Maven / Gradle / Ivy

Go to download

HyCube is a distributed hash table based on a hierarchical hypercube geometry, employing a novel variable metric adopting the Steinhaus transform.

There is a newer version: 1.0.5
Show newest version
package net.hycube.dht;

import net.hycube.backgroundprocessing.AbstractBackgroundProcess;
import net.hycube.backgroundprocessing.BackgroundProcessException;
import net.hycube.core.InitializationException;
import net.hycube.core.NodeAccessor;
import net.hycube.environment.NodeProperties;
import net.hycube.logging.LogHelper;

public class HyCubeDHTBackgroundProcess extends AbstractBackgroundProcess {

	private static org.apache.commons.logging.Log userLog = LogHelper.getUserLog();
	private static org.apache.commons.logging.Log devLog = LogHelper.getDevLog(HyCubeDHTBackgroundProcess.class); 
	
	

	protected HyCubeDHTManager dhtManager;
	
	
	
	
	@Override
	public void initialize(NodeAccessor nodeAccessor, NodeProperties properties) throws InitializationException {
		
		if (userLog.isDebugEnabled()) {
			userLog.debug("Initializing backround processing of DHT...");
		}
		if (devLog.isDebugEnabled()) {
			devLog.debug("Initializing backround processing of DHT...");
		}

		
		super.initialize(nodeAccessor, properties);

		
		try {
			this.dhtManager = (HyCubeDHTManager) nodeAccessor.getDHTManager();
			if (this.dhtManager == null) throw new InitializationException(InitializationException.Error.MISSING_EXTENSION_ERROR, null, "The DHTManager is not set.");
		} catch (ClassCastException e) {
			throw new InitializationException(InitializationException.Error.MISSING_EXTENSION_ERROR, null, "The DHTManager is expected to be an instance of: " + HyCubeDHTManager.class.getName());
		}
		
				
	}

	@Override
	public void doProcess() {
		
		processDHT();
		
	}

	
	
	protected void processDHT() {
		
		if (devLog.isDebugEnabled()) {
			devLog.debug("processDHT called");
		}
		
		try {
			dhtManager.processDHT();
		} catch (Exception e) {
			throw new BackgroundProcessException("An exception thrown while processing DHT.", e);
		}
    	
		
	}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy