⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oldcoveringroutingtable.java

📁 发布/订阅系统路由重配算法,可应用于ad hoc环境
💻 JAVA
字号:
///*// * project: RebecaSim// * package: broker// * file:    CoveringRoutingTable.java// * // * version: 0.1// * date:    05.05.2005// * // * This software is part of the diploma thesis "Ein adaptives Brokernetz // * für Publish/Subscribe Systeme".// *///package broker;////import java.util.*;/////////**// * TODO Insert class description here.// *// * @version 05.05.2005// * @author  parzy// *///public class OldCoveringRoutingTable extends OldRoutingTable {////	/**//	 * @param broker//	 *///	public OldCoveringRoutingTable(Broker local) {//		super(local);//		// TODO Auto-generated constructor stub//	}//	//	public OldDestinationSet subscribe(Broker from, Subscription s){//		Filter f;//		OldCoveringDestinationSet destinations;//		OldRoutingTable.Entry e;//		//		f = s.getFilter();//		destinations = new OldCoveringDestinationSet(local, from, s);////		// for each entry ensure idempotent operation//		for(Iterator it = table.iterator(); it.hasNext(); ){//			e = (Entry)it.next();//			//			if(from.equals(e.broker)){//				// ensure idempotent operation whether client or broker//				if(f.equals(e.filter)){//					destinations.clear();//					return destinations;//				}//				// remove really covered filter. Note we assume, that another//				// broker forwards only really upper filters.//				if((!from.equals(local)) && (f.covers(e.filter))){//					it.remove();//					// okay, für diesen eintrag müssen wir nix mehr machen//					continue;//				}//			}//			//			// müssen wir überhaupt noch nach covernden Filtern schauen?//			if(destinations.isFixed()){//				continue;//			}//			//			// Look for a covering RoutingEntry whether client or broker //			if(e.filter.covers(f)){//				destinations.restrictTo(e.broker);//			}//		}//		//		table.add(new Entry(f,from));//		return destinations;//	}//	//	public OldDestinationSet unsubscribe(Broker from, Unsubscription u){//		CoveringUnsubscription cu;//		if(u instanceof CoveringUnsubscription){//			cu = (CoveringUnsubscription)u;//		}else{//			cu = new CoveringUnsubscription(u.getFilter(), new LinkedList());//		}//		return unsubscribe(from, cu);//	}//	//	private OldDestinationSet unsubscribe(Broker from, CoveringUnsubscription u){//		Filter f;//		Filter uf;//		OldCoveringDestinationSet destinations;//		OldCoveringDestinationSet uncoveredDestinations;//		Entry e;//		Entry ue;//		boolean contained = false; // whether filter successfully removed//		LinkedList uncoveredEntries = new LinkedList();//		Broker src;//		//		f = u.getFilter();//		destinations = new OldCoveringDestinationSet(local, from, u);//		//		for(Iterator it = table.iterator(); it.hasNext(); ){//			e = (Entry)it.next();////			// eventuell die subscription entfernen.//			if(from.equals(e.broker)){//                // ensure idempotent operation whether client or broker//				if(f.equals(e.filter)){//					contained = true;//					it.remove();//					continue;//				}//				// an unsubscription cannot uncover any subscription from//				// the broker we received it from, since we would had removed//				// already when the subscription arrived.//				if(!from.equals(local)){//					continue;//				}//			}//			//			// müssen wir überhaupt noch nach covernden Filtern schauen?//			if(destinations.isFixed()){//				continue;//			}//			// Look for a covering or identical routing entry (whether from//			// client or broker)//			if(e.filter.covers(f)){//				destinations.restrictTo(e.broker);//			// nun die echten uncoverten Subscriptionen bestimmen//			}else if(f.covers(e.filter)){//				uncoveredEntries.add(e);//				e.markAsUndone();//			}//		}////		// unsubscription nicht gefunden, dann idempotentes replay and//		// nothing to do.//		if(!contained){//			destinations.clear();//			return destinations;//		}//		//		// add received uncovered Subscriptions to the routing table//		for(Iterator it = u.getUncoveredFilters().iterator(); it.hasNext(); ){//			ue = new Entry((Filter)it.next(), from);//			table.add(ue);//			uncoveredEntries.add(ue);//			ue.markAsUndone();//		}//		//		// müssen wir die subscription überhaupt forwarden?//		if(destinations.isFixed()){//			return destinations;//		}//		//		for(Iterator it = uncoveredEntries.iterator(); it.hasNext(); ){//			ue = (Entry)it.next();//			if(ue.isDone()){//				continue;//			}//			ue.markAsDone();//			uf = ue.filter;//			src = ue.broker;//			uncoveredDestinations=new OldCoveringDestinationSet(local,from,src,uf);//			//			for(Iterator jt = table.iterator(); jt.hasNext(); ){//				e = (Entry)jt.next();//				// identische nicht behandeln//				// oder wenn sich nix mehr ändern kann//				if(e == ue ){//					continue;//				}//				// falls fixed, dann raus hier//				if(uncoveredDestinations.isFixed()){//					break;//				}//				// falls uncovered filter neu überdeckt wird//				if(e.filter.covers(uf)){//					// falls beide identisch sind//					if(uf.covers(e.filter)){//						e.markAsDone();//						uncoveredDestinations.includeSrc();//					}else{//						// sonst //						uncoveredDestinations.restrictTo(e.broker);//					}//				}//			}//			//			destinations.addUncoveredFilters(uncoveredDestinations);			//		}//		//		return destinations;//	}//	//	public OldDestinationSet forward(Broker from, Notification n){//		OldCoveringDestinationSet destinations;//		Entry e;//		//		destinations = new OldCoveringDestinationSet(local, from, n);//		//		for(Iterator it = table.iterator(); it.hasNext(); ){//			e = (Entry)it.next();//			if(e.filter.match(n)){//				destinations.add(e.broker);//			}//		}//		return destinations;//	}//}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -