当前位置: 首页>>代码示例>>Java>>正文


Java FastConfig类代码示例

本文整理汇总了Java中peersim.config.FastConfig的典型用法代码示例。如果您正苦于以下问题:Java FastConfig类的具体用法?Java FastConfig怎么用?Java FastConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FastConfig类属于peersim.config包,在下文中一共展示了FastConfig类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: receiveLocked

import peersim.config.FastConfig; //导入依赖的package包/类
/**
 * Just received a locked message. Must acknowledge it.
 * 
 * @param from
 *            The node that sent the locked message.
 * @param to
 *            The node that must acknowledge the locked message.
 */
private void receiveLocked(Node from, Node to) {
	MUnlockBroadcast mu = new MUnlockBroadcast(from, to);
	Transport t = ((Transport) this.node.getProtocol(FastConfig.getTransport(PreventiveCausalBroadcast.pid)));

	APeerSampling ps = (APeerSampling) this.node.getProtocol(FastConfig.getLinkable(PreventiveCausalBroadcast.pid));
	List<Node> neighborhood = IteratorUtils.toList(ps.getAliveNeighbors().iterator());

	if (neighborhood.contains(from)) {
		t.send(this.node, from, mu, PreventiveCausalBroadcast.pid);
	} else {
		// just to check if it cannot send message because it has no
		PreventiveCausalBroadcast fcb = (PreventiveCausalBroadcast) from.getProtocol(PreventiveCausalBroadcast.pid);
		if (fcb.buffers.containsKey(to)) {
			System.out.println("NOT COOL");
		}
	}
}
 
开发者ID:Chat-Wane,项目名称:peersim-pcbroadcast,代码行数:26,代码来源:PreventiveCausalBroadcast.java

示例2: _sendToAllNeighbors

import peersim.config.FastConfig; //导入依赖的package包/类
/**
 * Send the reliable broadcast message to all neighbors, excepts ones still
 * buffering phase.
 * 
 * @param m
 *            The message to send.
 */
protected void _sendToAllNeighbors(MReliableBroadcast m) {
	APeerSampling ps = (APeerSampling) this.node.getProtocol(FastConfig.getLinkable(PreventiveCausalBroadcast.pid));

	for (Node q : ps.getAliveNeighbors()) {
		// (XXX) maybe remove q from peer-sampling, cause it may be
		// scrambled too quick.
		// Or maybe put
		// EDProtocol even for cycles. So all scrambles do not happen at a
		// same time.
		if (!this.buffers.containsKey(q)) {
			((Transport) this.node.getProtocol(FastConfig.getTransport(PreventiveCausalBroadcast.pid)))
					.send(this.node, q, m, PreventiveCausalBroadcast.pid);
		}
	}
}
 
开发者ID:Chat-Wane,项目名称:peersim-pcbroadcast,代码行数:23,代码来源:PreventiveCausalBroadcast.java

示例3: getRandomNeighbor

import peersim.config.FastConfig; //导入依赖的package包/类
/**
 * Returns a randomly selected neighbor of {@code self}.
 * 
 * @param self
 *            the calling node.
 * @param protocolID
 *            the ID of the {@link Linkable} protocol to use.
 * @return a randomly selected node from the neighbors of {@code self}, or
 *         {@code null} if {@code self} has no neighbors or the chosen
 *         neighbor is down.
 */
public static Node getRandomNeighbor(Node self, int protocolID)
{
	Linkable linkable = (Linkable) self.getProtocol(FastConfig.getLinkable(protocolID));

	if (linkable.degree() > 0)
	{
		Node neighbor = linkable.getNeighbor(CommonState.r.nextInt(linkable.degree()));

		if (neighbor.isUp())
		{
			return neighbor;
		}
	}

	return null;
}
 
开发者ID:darioseidl,项目名称:peersim-push-sum,代码行数:28,代码来源:ProtocolUtils.java

示例4: opened

import peersim.config.FastConfig; //导入依赖的package包/类
/**
 * A new neighbors has been added, the link must be acknowledged before it is
 * used.
 * 
 * @param n
 *            The new neighbor.
 */
public void opened(Node n, Node mediator) {
	APeerSampling ps = (APeerSampling) this.node.getProtocol(FastConfig.getLinkable(PreventiveCausalBroadcast.pid));
	List<Node> neighborhood = IteratorUtils.toList(ps.getAliveNeighbors().iterator());
	if (neighborhood.size() - this.buffers.size() >= 1) {
		this.buffers.put(n, new ArrayList<MReliableBroadcast>());
		this._sendLocked(n, mediator);
	}
}
 
开发者ID:Chat-Wane,项目名称:peersim-pcbroadcast,代码行数:16,代码来源:PreventiveCausalBroadcast.java

示例5: receiveAck

import peersim.config.FastConfig; //导入依赖的package包/类
/**
 * Just received an acknowledged message. Must empty the corresponding buffer
 * etc.
 * 
 * @param from
 *            We are the origin.
 * @param to
 *            The node that acknowledged our locked message.
 */
private void receiveAck(Node from, Node to) {
	if (this.buffers.containsKey(to)) {
		Transport t = ((Transport) this.node.getProtocol(FastConfig.getTransport(PreventiveCausalBroadcast.pid)));
		// #1 empty the buffer
		for (int i = 0; i < this.buffers.get(to).size(); ++i) {
			t.send(this.node, to, this.buffers.get(to).get(i), PreventiveCausalBroadcast.pid);
		}
		// #2 remove the entry from the buffer
		this.buffers.remove(to);
	}
}
 
开发者ID:Chat-Wane,项目名称:peersim-pcbroadcast,代码行数:21,代码来源:PreventiveCausalBroadcast.java

示例6: _sendToAllNeighbors

import peersim.config.FastConfig; //导入依赖的package包/类
/**
 * Send the reliable broadcast message to all neighbors.
 * 
 * @param m
 *            The message to send.
 */
protected void _sendToAllNeighbors(MReliableBroadcast m) {
	APeerSampling ps = (APeerSampling) this.node.getProtocol(FastConfig.getLinkable(ReliableBroadcast.pid));

	for (Node q : ps.getAliveNeighbors()) {
		this.rSend(q, m);
	}
}
 
开发者ID:Chat-Wane,项目名称:peersim-pcbroadcast,代码行数:14,代码来源:ReliableBroadcast.java

示例7: numberOfAliveNeighbors

import peersim.config.FastConfig; //导入依赖的package包/类
public Stats numberOfAliveNeighbors() {
	ArrayList<Double> sizes = new ArrayList<Double>();
	for (Node n : CDynamicNetwork.networks.get(0)) {
		APeerSampling ps = (APeerSampling) n.getProtocol(FastConfig.getLinkable(PreventiveCausalBroadcast.pid));
		List<Node> neighborhood = IteratorUtils.toList(ps.getAliveNeighbors().iterator());
		// FloodingCausalBroadcast fcb = (FloodingCausalBroadcast)
		// n.getProtocol(FloodingCausalBroadcast.pid);

		sizes.add((double) neighborhood.size());
	}

	return Stats.getFromSmall(sizes);
}
 
开发者ID:Chat-Wane,项目名称:peersim-pcbroadcast,代码行数:14,代码来源:DictGraph.java

示例8: tick

import peersim.config.FastConfig; //导入依赖的package包/类
public void tick(long currentTick, DictGraph observer) {
	Stats statsUnsafe = observer.numberOfUnSafe();
	StatsPair statsDistBiSprayAndFlood = observer.getStatsAboutDistances(20);
	Transport t = (Transport) CommonState.getNode()
			.getProtocol(FastConfig.getTransport(PreventiveCausalBroadcast.pid));

	System.out.println(t.getLatency(null, null) + " ||| " + observer.size() + " " + observer.countArcs() + " "
			+ observer.numberOfAliveNeighbors().mean + " ||| " + statsUnsafe.mean + " ||| "
			+ statsDistBiSprayAndFlood.a.mean + " ||| " + statsDistBiSprayAndFlood.b.mean);

}
 
开发者ID:Chat-Wane,项目名称:peersim-pcbroadcast,代码行数:12,代码来源:PBuffers.java

示例9: internalSend

import peersim.config.FastConfig; //导入依赖的package包/类
private void internalSend(final Message msg) {
  if (msg instanceof ChunkMessage) {
    sendLogger.logObject(new ChunkSendLog(msg.tag, msg.getClass().getSimpleName(), Utils.getSize(msg)
        + Common.currentConfiguration.messageHeaderSize, msg.sourceId.toString(), msg.destID.toString(), msg.isOverheadMessage(),
        ((ChunkMessage) msg).chunk.index));
  } else {
    sendLogger
    .logObject(new SendLog(msg.tag, msg.getClass().getSimpleName(), Utils.getSize(msg)
        + Common.currentConfiguration.messageHeaderSize, msg.sourceId.toString(), msg.destID.toString(), msg
        .isOverheadMessage()));
  }
  final Node peersimNode = (Node) nodeAddr.node;
  ((Transport) peersimNode.getProtocol(FastConfig.getTransport(protocolID))).send(peersimNode, (Node) msg.destID.node, msg,
      protocolID);
}
 
开发者ID:alibov,项目名称:StreamAid,代码行数:16,代码来源:PeersimNode.java

示例10: processEvent

import peersim.config.FastConfig; //导入依赖的package包/类
@Override
public void processEvent(Node self, int protocolID, Object event)
{
	// a timer message signaling the start of a new step
	if (event instanceof TimerMessage)
	{
		Node neighbor = ProtocolUtils.getRandomNeighbor(self, protocolID);

		if (neighbor != null)
		{
			// sum up
			value = valueBuffer;
			weight = weightBuffer;

			// send half of value and weight to self
			valueBuffer = value / 2;
			weightBuffer = weight / 2;

			// send half of value and weight to a random neighbor
			Transport transport = (Transport) self.getProtocol(FastConfig.getTransport(protocolID));
			transport.send(self, neighbor, new PushSumMessage(value / 2, weight / 2), protocolID);

		}

		// schedule a timer message for the next step
		EDSimulator.add(stepSize, new TimerMessage(), self, protocolID);

	}
	// a message from a neighbor
	else if (event instanceof PushSumMessage)
	{
		PushSumMessage message = (PushSumMessage) event;

		valueBuffer += message.getValue();
		weightBuffer += message.getWeight();
	}
}
 
开发者ID:darioseidl,项目名称:peersim-push-sum,代码行数:38,代码来源:PushSumED.java

示例11: rSend

import peersim.config.FastConfig; //导入依赖的package包/类
protected void rSend(Node node, MReliableBroadcast m) {
	((Transport) node.getProtocol(FastConfig.getTransport(ReliableBroadcast.pid))).send(this.node, node, m,
			ReliableBroadcast.pid);
}
 
开发者ID:Chat-Wane,项目名称:peersim-pcbroadcast,代码行数:5,代码来源:ReliableBroadcast.java

示例12: getEstimatedLatency

import peersim.config.FastConfig; //导入依赖的package包/类
@Override public long getEstimatedLatency(final NodeAddress key) {
  final int tranportID = FastConfig.getTransport(protocolID);
  final Transport transport = (Transport) node.getProtocol(tranportID);
  return transport.getLatency(node, (Node) key.node);
}
 
开发者ID:alibov,项目名称:StreamAid,代码行数:6,代码来源:PeersimNode.java

示例13: _sendLocked

import peersim.config.FastConfig; //导入依赖的package包/类
/**
 * Send a locked message to a remote peer that we want to add in our
 * neighborhood.
 * 
 * @param to
 *            The peer to reach.
 */
private void _sendLocked(Node to, Node mediator) {
	MLockedBroadcast mlb = new MLockedBroadcast(this.node, to);

	Transport t = ((Transport) this.node.getProtocol(FastConfig.getTransport(PreventiveCausalBroadcast.pid)));
	t.send(this.node, mediator, new MForward(to, mlb), PreventiveCausalBroadcast.pid);
}
 
开发者ID:Chat-Wane,项目名称:peersim-pcbroadcast,代码行数:14,代码来源:PreventiveCausalBroadcast.java

示例14: onForward

import peersim.config.FastConfig; //导入依赖的package包/类
/**
 * Forward a message to a remote peer.
 * 
 * @param to
 *            The peer to forward the message to.
 * @param message
 *            The message to forward.
 */
private void onForward(Node to, IMessage message) {
	((Transport) this.node.getProtocol(FastConfig.getTransport(PreventiveCausalBroadcast.pid))).send(this.node, to,
			message, PreventiveCausalBroadcast.pid);
}
 
开发者ID:Chat-Wane,项目名称:peersim-pcbroadcast,代码行数:13,代码来源:PreventiveCausalBroadcast.java


注:本文中的peersim.config.FastConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。