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

es.tid.tedb.MultiLayerTEDB Maven / Gradle / Ivy

The newest version!
package es.tid.tedb;

import es.tid.ospf.ospfv2.lsa.tlv.subtlv.complexFields.BitmapLabelSet;
import org.jgrapht.graph.SimpleDirectedWeightedGraph;

import java.net.Inet4Address;
import java.util.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;


public class MultiLayerTEDB implements DomainTEDB {
	
	private ArrayList registeredAlgorithms;
	/**
	 * Graph of the Upper Layer Network
	 */
	/**
	 * 
	 */
	private SimpleDirectedWeightedGraph upperLayerGraph;

	/**
	 * Graph of the Upper Layer Network
	 */
	private SimpleDirectedWeightedGraph lowerLayerGraph;

	/**
	 * InterLayer Graph
	 */
	private SimpleDirectedWeightedGraph interLayerGraph;
	/**
	 * Reachability information
	 */
	private ReachabilityEntry reachabilityEntry;

	/**
	 * WSON Information of the lower Layer
	 */
	private WSONInformation WSONinfo=null;
	
	private Lock TEDBlock;
	

	/**
	 * List of interdomain Links
	 */
	private LinkedList interDomainLinks; 
	
	private Hashtable RelationNodesInterlayer;
	
	


	public MultiLayerTEDB(){
		registeredAlgorithms= new ArrayList(); 
		TEDBlock=new ReentrantLock();
	}
	
	
	public SimpleDirectedWeightedGraph getUpperLayerGraph() {
		return upperLayerGraph;
	}

	public void setUpperLayerGraph(
			SimpleDirectedWeightedGraph upperLayerGraph) {
		this.upperLayerGraph = upperLayerGraph;
	}

	
	public SimpleDirectedWeightedGraph getLowerLayerGraph() {
		return lowerLayerGraph;
	}

	public void setLowerLayerGraph(
			SimpleDirectedWeightedGraph lowerLayerGraph) {
		this.lowerLayerGraph = lowerLayerGraph;
	}

	
	public SimpleDirectedWeightedGraph getInterLayerGraph() {
		return interLayerGraph;
	}

	public void setInterLayerGraph(
			SimpleDirectedWeightedGraph interLayerGraph) {
		this.interLayerGraph = interLayerGraph;
	}



	public SimpleDirectedWeightedGraph getDuplicatedUpperLayerkGraph(){
		SimpleDirectedWeightedGraph graphCopy;
		TEDBlock.lock();
		try{
			graphCopy= (SimpleDirectedWeightedGraph) upperLayerGraph.clone();
		} finally{
			TEDBlock.unlock();
		}
		return graphCopy;
	}
	public Hashtable getRelationNodesInterlayer() {
		return RelationNodesInterlayer;
	}
	public SimpleDirectedWeightedGraph getDuplicatedLowerLayerkGraph(){
		SimpleDirectedWeightedGraph graphCopy;
		TEDBlock.lock();
		try{
			graphCopy= (SimpleDirectedWeightedGraph) lowerLayerGraph.clone();
		} finally{
			TEDBlock.unlock();
		}
		return graphCopy;
	}
	
	public SimpleDirectedWeightedGraph getDuplicatedInterLayerGraph(){
		SimpleDirectedWeightedGraph graphCopy;
		TEDBlock.lock();
		try{
			graphCopy= (SimpleDirectedWeightedGraph) interLayerGraph.clone();
		} finally{
			TEDBlock.unlock();
		}
		return graphCopy;
	}

	public void initializeFromFile(String file) {
		upperLayerGraph=FileTEDBUpdater.readNetwork(file, "mpls");	
		lowerLayerGraph=FileTEDBUpdater.readNetwork(file, "wson");
		interLayerGraph=FileTEDBUpdater.readNetwork(file, "interlayer");
		WSONinfo = FileTEDBUpdater.getWSONInformation(file, "wson");
		interDomainLinks = FileTEDBUpdater.readInterDomainLinks(file);	
		
		reachabilityEntry = new ReachabilityEntry();
		//domainReachabilityIPv4Prefix=new byte[4];
		FileTEDBUpdater.getDomainReachabilityFromFile(file,reachabilityEntry,"mpls");
	}

	@Override
	public void initializeFromFile(String file, String learnFrom) {

	}

	@Override
	public boolean isITtedb() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public String printTopology() {
		String topoString;
		Set vetexSet= upperLayerGraph.vertexSet();
		Iterator  vertexIterator=vetexSet.iterator();
		topoString="MPLS Nodes: \r\n";
		while (vertexIterator.hasNext()){
			Object vertex= vertexIterator.next();
			topoString=topoString+"\t"+vertex.toString()+"\r\n";
		}
		topoString=topoString+"MPLS Link list: \r\n";
		Set edgeSet= upperLayerGraph.edgeSet();
		Iterator  edgeIterator=edgeSet.iterator();
		while (edgeIterator.hasNext()){
			IntraDomainEdge edge= edgeIterator.next();
			topoString=topoString+"\t"+edge.toString()+"\r\n";
		}
		vetexSet= lowerLayerGraph.vertexSet();
		vertexIterator=vetexSet.iterator();
		topoString="GMPLS Nodes: \r\n";
		while (vertexIterator.hasNext()){
			Object vertex= vertexIterator.next();
			topoString=topoString+"\t"+vertex.toString()+"\r\n";
		}
		topoString=topoString+"gmpls Link list: \r\n";
		edgeSet= lowerLayerGraph.edgeSet();
		edgeIterator=edgeSet.iterator();
		while (edgeIterator.hasNext()){
			IntraDomainEdge edge= edgeIterator.next();
			topoString=topoString+"\t"+edge.toString()+"\r\n";
		}
		topoString=topoString+"InterLayer list: \r\n";
		edgeSet= interLayerGraph.edgeSet();
		edgeIterator=edgeSet.iterator();
		while (edgeIterator.hasNext()){
			IntraDomainEdge edge= edgeIterator.next();
			topoString=topoString+"\t"+edge.toString()+"\r\n";
		}
		
		topoString=topoString+printInterDomainLinks();
		return topoString;
	}

	@Override
	public boolean belongsToDomain(Object addr) {
		int i;
		byte[] addrbytes= ((Inet4Address)addr).getAddress();
		for (i=0;i<4;++i){
			addrbytes[i]=(byte) (addrbytes[i]&(reachabilityEntry.getMask())[i]);
		}
		return Arrays.equals(addrbytes,reachabilityEntry.getAggregatedIPRange().getAddress());
	}

	public ReachabilityEntry getReachabilityEntry() {
		return reachabilityEntry;
	}

	public LinkedList getInterDomainLinks() {
		return interDomainLinks;
	}

	@Override
	public String printInterDomainLinks(){
		String topoString="";

		int size = interDomainLinks.size();
		topoString="Interdomain Link list: \r\n";
		for (int i=0;i sourceVertexList, LinkedList targetVertexList, int wavelength, boolean bidirectional){
		TEDBlock.lock();
		try {
			for (int i=0;i sourceVertexList, LinkedList targetVertexList, int wavelength, boolean bidirectional){
		// TODO Auto-generated method stub
		//Delete the resource reservation
		TEDBlock.lock();
		try {
			for (int i=0;i graph= ted.getNetworkGraph();
				IntraDomainEdge edge=lowerLayerGraph.getEdge(sourceVertexList.get(i),targetVertexList.get(i) );
				edge.getTE_info().setWavelengthUnReserved(wavelength);
				if (bidirectional == true)
				{
					edge=lowerLayerGraph.getEdge(targetVertexList.get(i), sourceVertexList.get(i));
					edge.getTE_info().setWavelengthUnReserved(wavelength);
				}
			}
		}finally{
			TEDBlock.unlock();
		}
		for (int i=0;i edgeSet= lowerLayerGraph.edgeSet();
				Iterator  edgeIterator=edgeSet.iterator();
				while (edgeIterator.hasNext()){
					IntraDomainEdge edge= edgeIterator.next();
					edge.TE_info.setAllWavelengtshUnReserved();
				}
			}finally{
				TEDBlock.unlock();
			}
			for (int i=0;i sourceVertexList,
			LinkedList targetVertexList, int wavelength,
			boolean bidirectional, int m) {
		// TODO Auto-generated method stub
	}

	@Override
	public void notifyWavelengthReservationSSON(
			LinkedList sourceVertexList,
			LinkedList targetVertexList, int wavelength,
			boolean bidirectional, int m) {
		// TODO Auto-generated method stub
	}

	@Override
	public SSONInformation getSSONinfo() {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public Set getIntraDomainLinks() {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public void notifyWavelengthReservationWLAN(
			LinkedList sourceVertexList,
			LinkedList targetVertexList,
			LinkedList wlans, boolean bidirectional) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void registerSSON(SSONListener compAlgPreComp) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public Inet4Address getDomainID() {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public void setWSONinfo(WSONInformation wSONinfo) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void setSSONinfo(SSONInformation sSONinfo) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void createGraph() {
		// TODO Auto-generated method stub
		
	}


	@Override
	public Set getIntraDomainLinksvertexSet() {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public Hashtable getNodeTable() {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public IT_Resources getItResources() {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public void setItResources(IT_Resources itResources) {
		// TODO Auto-generated method stub
		
	}
}