本文整理汇总了Java中es.tid.util.UtilsFunctions类的典型用法代码示例。如果您正苦于以下问题:Java UtilsFunctions类的具体用法?Java UtilsFunctions怎么用?Java UtilsFunctions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UtilsFunctions类属于es.tid.util包,在下文中一共展示了UtilsFunctions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendRequest
import es.tid.util.UtilsFunctions; //导入依赖的package包/类
private void sendRequest(DataOutputStream out, PCEPMessage telinkconf) {
try
{
if (out==null)
System.out.println("El out es null!!!");
else{
log.info("Sending request to VNTM");
log.info("telinkconf::"+telinkconf.toString());
out.write(telinkconf.getBytes());
out.flush();
}
} catch (IOException e)
{
log.info(UtilsFunctions.exceptionToString(e));
}
}
示例2: telnetInformPCE
import es.tid.util.UtilsFunctions; //导入依赖的package包/类
private void telnetInformPCE(String sourceSwitchID, String destSwitchID, Integer source_interface, Integer destination_interface)
{
try
{
log.info("Calling PCE to add link by telnet");
Socket connectionToTheServer = new Socket("localhost", 6666);
OutputStream out = connectionToTheServer.getOutputStream();
PrintStream ps = new PrintStream(out, true);
ps.println("add xifi link");
BufferedReader br = new BufferedReader(new InputStreamReader(connectionToTheServer.getInputStream()));
log.info(br.readLine());
log.info("commmand::"+sourceSwitchID+"-"+destSwitchID+"-"+source_interface+"-" + destination_interface);
ps.println(sourceSwitchID+"-"+destSwitchID+"-"+source_interface+"-" + destination_interface);
//ps.println("10:00:2c:59:e5:66:ed:00:19-10:00:2c:59:e5:5e:2b:00:19-2-4");
connectionToTheServer.close();
}
catch (Exception e)
{
log.info(UtilsFunctions.exceptionToString(e));
}
}
示例3: sendPCEPMessage
import es.tid.util.UtilsFunctions; //导入依赖的package包/类
synchronized public void sendPCEPMessage(PCEPMessage msg){
try {
msg.encode();
} catch (PCEPProtocolViolationException e1) {
// TODO Auto-generated catch block
log.info(UtilsFunctions.exceptionToString(e1));
}
try {
log.info("Sending message ::"+msg);
out.write(msg.getBytes());
out.flush();
log.info("Sending message finish");
} catch (IOException e) {
log.info(UtilsFunctions.exceptionToString(e));
log.warn("Error sending msg: " + e.getMessage());
}
}
示例4: sendRequest
import es.tid.util.UtilsFunctions; //导入依赖的package包/类
private void sendRequest(DataOutputStream out, PCEPMessage reportconf) {
try
{
if (out==null)
System.out.println("El out es null!!!");
else{
log.info("Sending request to VNTM");
log.info("reportconf::"+reportconf.toString());
out.write(reportconf.getBytes());
out.flush();
}
} catch (IOException e)
{
log.info(UtilsFunctions.exceptionToString(e));
}
}
示例5: addnewLSP
import es.tid.util.UtilsFunctions; //导入依赖的package包/类
/**
* Method to create a new TE LSP initiated in this node
* @param destinationId IP AddreStart LSP Errorss of the destination of the LSP
* @param bw Bandwidth requested
* @param bidirectional bidirectional
* @param OFcode
* @throws LSPCreationException
*/
public long addnewLSP(Inet4Address destinationId, float bw, boolean bidirectional, int OFcode) throws LSPCreationException{
log.info("Adding New LSP to "+destinationId);
//FIXME: mirar esto
//meter structura --> RequestedLSPinformation --> Dependiente de cada tecnologia
//meter campo con el estado del LSP e ir cambiandolo
LSPTE lsp = new LSPTE(this.getIdNewLSP(), localIP, destinationId, bidirectional, OFcode, bw, PathStateParameters.creatingLPS);
LSPList.put(new LSPKey(localIP, lsp.getIdLSP()), lsp);
ReentrantLock lock= new ReentrantLock();
Condition lspEstablished =lock.newCondition();
//log.info("Metemos en Lock list con ID: "+lsp.getIdLSP());
lockList.put(lsp.getIdLSP(), lock);
conditionList.put(lsp.getIdLSP(), lspEstablished);
/*log.info("Size lockList : "+lockList.size());
log.info("Size conditionList : "+conditionList.size());*/
timeIni = System.nanoTime();
log.info("Start to establish path: "+System.nanoTime());
try{
startLSP(lsp);
}catch(LSPCreationException e){
log.info("Start LSP Error!");
conditionList.remove(lsp.getIdLSP());
lockList.remove(lsp.getIdLSP());
LSPList.remove(lsp.getIdLSP());
log.info(UtilsFunctions.exceptionToString(e));
throw e;
}
return lsp.getIdLSP();
}
示例6: sleep
import es.tid.util.UtilsFunctions; //导入依赖的package包/类
private void sleep(int s)
{
try
{
Thread.currentThread().sleep(s);
}
catch (InterruptedException e)
{
log.info(UtilsFunctions.exceptionToString(e));
}
}
示例7: replyOK
import es.tid.util.UtilsFunctions; //导入依赖的package包/类
protected void replyOK()
{
try
{
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().println("<html><body><p>Everything OK</p></body></html>");
}
catch (IOException e)
{
log.info(UtilsFunctions.exceptionToString(e));
}
}
示例8: replyError
import es.tid.util.UtilsFunctions; //导入依赖的package包/类
/**
* This is really replying Internal Server Error (500)
*/
protected void replyError()
{
try
{
response.setHeader("Content-Type", "application/json");
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
catch (IOException e)
{
log.info(UtilsFunctions.exceptionToString(e));
}
}
示例9: replyClientError
import es.tid.util.UtilsFunctions; //导入依赖的package包/类
/**
* This is really replying Client Server Error (400)
* The request sent by the client was syntactically incorrect.
*/
protected void replyClientError()
{
try
{
response.setHeader("Content-Type", "application/json");
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
}
catch (IOException e)
{
log.info(UtilsFunctions.exceptionToString(e));
}
}
示例10: reply
import es.tid.util.UtilsFunctions; //导入依赖的package包/类
/**
* @param code : code that will be sent
*/
protected void reply(int code)
{
try
{
response.setStatus(code);
response.getWriter().println("<html><body><p>Code :"+code+" </p></body></html>");
}
catch (IOException e)
{
log.info(UtilsFunctions.exceptionToString(e));
}
}
示例11: replyMessage
import es.tid.util.UtilsFunctions; //导入依赖的package包/类
/**
*
* @param message : message
*/
protected void replyMessage(String message)
{
//response.setHeader("Content-Type", "text/plain");
response.setHeader("Content-Type", "application/json");
try
{
response.getWriter().println(message);
//response.getWriter().println("<html><body><p>Code :"+message+" </p></body></html>");
}
catch (IOException e)
{
log.info(UtilsFunctions.exceptionToString(e));
}
}
示例12: calculatePath
import es.tid.util.UtilsFunctions; //导入依赖的package包/类
public PCEPResponse calculatePath(String ipSourceString, String ipDestString) {
this.log.info("** PCE **");
this.log.info("Calculating cost between " + ipSourceString + " and " + ipDestString);
try
{
Inet4Address ipSource = (Inet4Address)Inet4Address.getByName(ipSourceString);
Inet4Address ipDest = (Inet4Address)Inet4Address.getByName(ipDestString);
PCEPRequest p_r = new PCEPRequest();
Request req = new Request();
p_r.addRequest(req);
RequestParameters rp = new RequestParameters();
rp.setPbit(true);
req.setRequestParameters(rp);
rp.setRequestID(PCCPCEPSession.getNewReqIDCounter());
EndPointsIPv4 ep = new EndPointsIPv4();
req.setEndPoints(ep);
ep.setSourceIP(ipSource);
ep.setDestIP(ipDest);
ObjectiveFunction of = new ObjectiveFunction();
of.setOFcode(this.ofCode);
req.setObjectiveFunction(of);
/*float bw = 100.0F;
Bandwidth bandwidth = new Bandwidth();
bandwidth.setBw(bw);
req.setBandwidth(bandwidth);
*/
PCEPResponse pr = this.crm.newRequest(p_r);
this.log.info("Response from PCE " + pr.toString());
return pr;
}
catch (Exception e) {
this.log.info("Exception");
this.log.info(UtilsFunctions.exceptionToString(e));
}return null;
}
示例13: createInitAndSend
import es.tid.util.UtilsFunctions; //导入依赖的package包/类
private void createInitAndSend(EroAndIP EaIP)
{
PCEPInitiate pInit = new PCEPInitiate();
LinkedList<PCEPIntiatedLSP> pcepIntiatedLSPList = new LinkedList<PCEPIntiatedLSP>();
PCEPIntiatedLSP pILSP = new PCEPIntiatedLSP();
LSP lsp = new LSP();
SRP rsp = new SRP();
ExplicitRouteObject ero_lsp = EaIP.ero;
pILSP.setLsp(lsp);
pILSP.setRsp(rsp);
pILSP.setEro(ero_lsp);
pcepIntiatedLSPList.add(pILSP);
try
{
pInit.encode();
Socket clientSocket;
clientSocket = new Socket(EaIP.address, 2222);
DataOutputStream out_to_node = new DataOutputStream(clientSocket.getOutputStream());
out_to_node.write(pInit.getBytes());
out_to_node.flush();
}
catch (Exception e)
{
log.info(UtilsFunctions.exceptionToString(e));
}
}
示例14: newRequest
import es.tid.util.UtilsFunctions; //导入依赖的package包/类
public PCEPMessage newRequest( PCEPMessage pcreq, long maxTimeMs)
{
log.info("New Request. Request:"+pcreq.toString());
Object object_lock = new Object();
long idRequest = generateRandomID();
Long idReqLong = new Long(idRequest);
long timeIni = System.nanoTime();
locks.put(idReqLong, object_lock);
sendPCEPMessage(pcreq);
synchronized (object_lock)
{
try
{
log.info("ESPERAREMOS "+maxTimeMs);
object_lock.wait(maxTimeMs);
}
catch (InterruptedException e)
{
UtilsFunctions.exceptionToString(e);
}
}
long timeIni2=System.nanoTime();
double reqTime_ms=(timeIni2-timeIni)/1000000;
log.debug("Request or timeout");
PCEPMessage resp = responses.remove(new Long(idRequest));
if (resp==null)
{
log.warn("NO RESPONSE!!!!! me deshago del lock... con idReqLong "+idRequest);
locks.remove(idReqLong);
}
return resp;
}
示例15: initiate
import es.tid.util.UtilsFunctions; //导入依赖的package包/类
public PCEPMessage initiate ( PCEPInitiate pcini, long maxTimeMs)
{
log.info("Sending Initiate:"+pcini.toString());
byte[] LSPname=pcini.getPcepIntiatedLSPList().get(0).getLsp().getSymbolicPathNameTLV_tlv().getSymbolicPathNameID();
long idIni=pcini.getPcepIntiatedLSPList().get(0).getRsp().getSRP_ID_number();
System.out.println("Sending with id " +idIni);
Long idReqLong=new Long(idIni);
long timeIni=System.nanoTime();
//System.out.println("id ini es "+)
Semaphore semapohore=new Semaphore(0);
semaphores.put(idIni, semapohore);
sendPCEPMessage(pcini);
try
{
semapohore.tryAcquire(maxTimeMs,TimeUnit.MILLISECONDS);
}
catch (InterruptedException e)
{
UtilsFunctions.exceptionToString(e);
}
long timeIni2=System.nanoTime();
//log.info("Response "+pr.toString());
double reqTime_ms=(timeIni2-timeIni)/1000000;
log.debug("Time: "+reqTime_ms );
PCEPMessage resp=responsesInit.remove(new Long(idIni));
if (resp==null){
log.warn("NO RESPONSE!!!!! me deshago del lock... con idIni "+idIni);
locks.remove(idReqLong);
}
return resp;
}