本文整理汇总了Java中ibis.ipl.SendPort类的典型用法代码示例。如果您正苦于以下问题:Java SendPort类的具体用法?Java SendPort怎么用?Java SendPort使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SendPort类属于ibis.ipl包,在下文中一共展示了SendPort类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSendPort
import ibis.ipl.SendPort; //导入依赖的package包/类
private SendPort getSendPort() {
if (closed) {
return null;
}
if (!connected) {
if (commLogger.isDebugEnabled()) {
commLogger.debug("CASHMERE '" + sendPort.identifier().ibisIdentifier()
+ "': connecting to " + ident);
}
r = Communication.connect(sendPort, ident, "cashmere port",
Cashmere.CONNECT_TIMEOUT);
if (r == null) {
commLogger.warn("CASHMERE '" + sendPort.identifier().ibisIdentifier()
+ "': unable to connect to " + ident
+ ", might have crashed");
return null;
}
connected = true;
connectionCount++;
}
return sendPort;
}
示例2: startSenderPort
import ibis.ipl.SendPort; //导入依赖的package包/类
/**
*
* Creates a new SendPort and connects to the receiver.
*
* @param senderPortType
* The type of the sender port.
* @param senderPort
* The name of the sender port.
* @param receiver
* The Ibis instance that receives messages.
* @param receiverPort
* The name of the receiver.
* @return The port that is created.
*/
private SendPort startSenderPort(PortType senderPortType,
String senderPort, IbisIdentifier receiver, String receiverPort) {
SendPort port = null;
Ibis ibis = receiverPort.equals(queryReceiverPort) ? clientIbis
: clusterIbis;
try {
port = ibis.createSendPort(senderPortType, senderPort);
port.connect(receiver, receiverPort);
if (port.connectedTo() != null) {
senderPorts.put(senderPort, port);
return port;
} else {
return null; // Connected to any resource
}
} catch (Exception e) {
log.error("Failed in creating the sender port " + senderPort
+ "to node " + receiver, e);
}
return port;
}
示例3: disconnect
import ibis.ipl.SendPort; //导入依赖的package包/类
public static void disconnect(SendPort s, ReceivePortIdentifier ident) {
try {
s.disconnect(ident);
} catch (IOException e) {
// ignored
}
}
示例4: Victim
import ibis.ipl.SendPort; //导入依赖的package包/类
public Victim(IbisIdentifier ident, SendPort s) {
this.ident = ident;
this.sendPort = s;
if (s != null) {
inDifferentCluster = !clusterOf(ident).equals(clusterOf(s.identifier().ibisIdentifier()));
} else {
inDifferentCluster = false;
}
}
示例5: newMessage
import ibis.ipl.SendPort; //导入依赖的package包/类
public WriteMessage newMessage() throws IOException {
SendPort send;
synchronized (sendPort) {
send = getSendPort();
if (send != null) {
referenceCount++;
} else {
throw new IOException("CASHMERE '" + sendPort.identifier().ibisIdentifier()
+ "': Could not connect to " + ident);
}
}
return send.newMessage();
}
示例6: lostConnection
import ibis.ipl.SendPort; //导入依赖的package包/类
public void lostConnection(SendPort me, ReceivePortIdentifier johnDoe,
Throwable reason) {
if (ftLogger.isInfoEnabled()) {
ftLogger.info("CASHMERE '" + s.ident
+ "': got SENDPORT lostConnection upcall: "
+ johnDoe.ibisIdentifier(), reason);
}
if (connectionUpcallsDisabled) {
return;
}
handleLostConnection(johnDoe.ibisIdentifier());
}
示例7: getMessageToSend
import ibis.ipl.SendPort; //导入依赖的package包/类
/**
* Creates a new message for the port that has the name of the receiverPort
* concatenated with the name of the receiver. If such a port does not
* exists it is created.
*
* @param receiver
* The identifier of the Ibis that will receive the message.
* @param receiverPort
* The name of the port.
* @return A new WriteMessage object constructed for the parameters of the
* method.
* @throws IOException
*/
public WriteMessage getMessageToSend(IbisIdentifier receiver,
String receiverPort) throws IOException {
SendPort port = null;
String nameSenderPort = receiverPort + receiver.name();
if (!senderPorts.containsKey(nameSenderPort)) {
synchronized (NetworkLayer.class) {
if (!senderPorts.containsKey(nameSenderPort)) {
PortType type = null;
if (receiverPort.equals(queryReceiverPort)) {
type = queryAnswerPortType;
} else if (receiverPort.equals(nameMgmtReceiverPort)) {
type = mgmtRequestPortType;
} else if (receiverPort.equals(nameBcstReceiverPort)) {
type = broadcastPortType;
} else {
type = requestPortType;
}
startSenderPort(type, nameSenderPort, receiver,
receiverPort);
}
}
}
port = senderPorts.get(nameSenderPort);
WriteMessage w = port.newMessage();
timers.put(nameSenderPort, System.currentTimeMillis());
return w;
}
示例8: finishMessage
import ibis.ipl.SendPort; //导入依赖的package包/类
/**
* Finishes sending the message msg and adds at the counters informations
* about the sending time and the bytes that were sent.
*
* @param msg
* The message that was sent.
* @param submissionId
* The subbmission id.
* @throws IOException
*/
public void finishMessage(WriteMessage msg, int submissionId)
throws IOException {
SendPort p = msg.localPort();
long bytes = msg.finish();
long startTime = timers.get(p.name());
stats.addCounter(0, submissionId,
"NetworkLayer: time sending msgs (ms)",
System.currentTimeMillis() - startTime);
stats.addCounter(0, submissionId, "NetworkLayer: bytes sent", bytes);
// stats.addCounter(0, submissionId, "Messages sent", 1);
}