/** * We lost the task tracker! All task-tracker structures have already been updated. Just process * the contained tasks and any jobs that might be affected. */ void lostTaskTracker(String trackerName) { LOG.info("Lost tracker '" + trackerName + "'"); TreeSet lostTasks = (TreeSet) trackerToTaskMap.get(trackerName); trackerToTaskMap.remove(trackerName); if (lostTasks != null) { for (Iterator it = lostTasks.iterator(); it.hasNext(); ) { String taskId = (String) it.next(); TaskInProgress tip = (TaskInProgress) taskidToTIPMap.get(taskId); // Tell the job to fail the relevant task JobInProgress job = tip.getJob(); job.failedTask(tip, taskId, trackerName); } } }
private void ConnectKnowledgeBaseBtnMouseClicked( java.awt.event.MouseEvent evt) { // GEN-FIRST:event_ConnectKnowledgeBaseBtnMouseClicked String sPrjFile = ProjectNameTF.getText().trim(); String sLocationURI = sURI + "Location"; Collection errors = new ArrayList(); Date d1 = new Date(); long l1 = d1.getTime(); prj = Project.loadProjectFromFile(sPrjFile, errors); owlModel = (OWLModel) prj.getKnowledgeBase(); kb = prj.getKnowledgeBase(); URI uri = prj.getActiveRootURI(); Collection colNumberOfInstance = kb.getInstances(); lNumberOfInstance = colNumberOfInstance.size(); Date d2 = new Date(); long l2 = d2.getTime(); lLoadedTime = (l2 - l1); theLogger.info("Connected to MySQL in " + lLoadedTime + " ms"); theLogger.info("KB has " + lNumberOfInstance + " instances"); LoggingAreaTA.append("Project has " + lNumberOfInstance + " in total\n"); LoggingAreaTA.append("Project is loaded in " + lLoadedTime + " ms\n"); } // GEN-LAST:event_ConnectKnowledgeBaseBtnMouseClicked
/** 基类实现消息监听接口,加上打印metaq监控日志的方法 */ @Override public ConsumeConcurrentlyStatus consumeMessage( List<MessageExt> msgs, ConsumeConcurrentlyContext context) { long startTime = System.currentTimeMillis(); logger.info("receive_message:{}", msgs.toString()); if (msgs == null || msgs.size() < 1) { logger.error("receive empty msg!"); return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; } List<Serializable> msgList = new ArrayList<>(); for (MessageExt message : msgs) { msgList.add(decodeMsg(message)); } final int reconsumeTimes = msgs.get(0).getReconsumeTimes(); MsgObj msgObj = new MsgObj(); msgObj.setReconsumeTimes(reconsumeTimes); msgObj.setMsgList(msgList); msgObj.setContext(context); context.setDelayLevelWhenNextConsume(getDelayLevelWhenNextConsume(reconsumeTimes)); ConsumeConcurrentlyStatus status = doConsumeMessage(msgObj); logger.info( "ConsumeConcurrentlyStatus:{}|cost:{}", status, System.currentTimeMillis() - startTime); return status; }
void _pickInitial() throws MongoException { if (_curAddress != null) return; // we need to just get a server to query for ismaster _pickCurrent(); try { _logger.info("current address beginning of _pickInitial: " + _curAddress); DBObject im = isMasterCmd(); if (_isMaster(im)) return; synchronized (_allHosts) { Collections.shuffle(_allHosts); for (ServerAddress a : _allHosts) { if (_curAddress == a) continue; _logger.info("remote [" + _curAddress + "] -> [" + a + "]"); _set(a); im = isMasterCmd(); if (_isMaster(im)) return; _logger.severe("switched to: " + a + " but isn't master"); } throw new MongoException("can't find master"); } } catch (Exception e) { _logger.log(Level.SEVERE, "can't pick initial master, using random one", e); } }
public DBTCPConnector(Mongo m, ServerAddress addr) throws MongoException { _mongo = m; _portHolder = new DBPortPool.Holder(m._options); _checkAddress(addr); _createLogger.info(addr.toString()); if (addr.isPaired()) { _allHosts = new ArrayList<ServerAddress>(addr.explode()); _createLogger.info("switch to paired mode : " + _allHosts + " -> " + _curAddress); } else { _set(addr); _allHosts = null; } }
// methods start,stop,forward,rewind,insert-time,position moved as static to h4JmfPlugin // kleine delay inbouwen forward,rewind ???,sometimes player does not respind well ?? why?? // EBComponent interface public void handleMessage(EBMessage message) { logger.info(message.toString()); if (message instanceof PropertiesChanged) { // propertiesChanged(); } // AWT-EventQueue-0: INFO: EditorExiting[source=null] else if (message instanceof org.gjt.sp.jedit.msg.PluginUpdate) { Object what = ((PluginUpdate) message).getWhat(); if (what.equals(PluginUpdate.DEACTIVATED)) { // if(h4JmfPlugin.playMP3!=null) h4JmfPlugin.playMP3.close(); // h4JmfPlugin.playMP3=null; logger.info("close done in h4JmfPlugin"); } } // PluginUpdate } // handleMessage
/* * return 0 is success, otherwise failure */ public final int runAdminCommandOnRemoteNode( Node thisNode, StringBuilder output, List<String> args, List<String> stdinLines) throws SSHCommandExecutionException, IllegalArgumentException, UnsupportedOperationException { String humanreadable = null; try { this.node = thisNode; dcomInfo = new DcomInfo(node); List<String> fullcommand = new ArrayList<String>(); WindowsRemoteAsadmin asadmin = dcomInfo.getAsadmin(); if (stdinLines != null && !stdinLines.isEmpty()) setupAuthTokenFile(fullcommand, stdinLines); fullcommand.addAll(args); humanreadable = dcomInfo.getNadminPath() + " " + commandListToString(fullcommand); // This is where the rubber meets the road... String out = asadmin.run(fullcommand); output.append(out); logger.info(Strings.get("remote.command.summary", humanreadable, out)); return determineStatus(args); } catch (WindowsException ex) { throw new SSHCommandExecutionException( Strings.get("remote.command.error", ex.getMessage(), humanreadable), ex); } finally { teardownAuthTokenFile(); } }
void setConfig(Configuration config) { log.debug("config: " + config); proxyHost = config.get(PARAM_PROXY_HOST); proxyPort = config.getInt(PARAM_PROXY_PORT, DEFAULT_PROXY_PORT); if (StringUtil.isNullString(proxyHost) || proxyPort <= 0) { String http_proxy = System.getenv("http_proxy"); if (!StringUtil.isNullString(http_proxy)) { try { HostPortParser hpp = new HostPortParser(http_proxy); proxyHost = hpp.getHost(); proxyPort = hpp.getPort(); } catch (HostPortParser.InvalidSpec e) { log.warning("Can't parse http_proxy environment var, ignoring: " + http_proxy + ": " + e); } } } if (StringUtil.isNullString(proxyHost) || proxyPort <= 0) { proxyHost = null; } else { log.info("Proxying through " + proxyHost + ":" + proxyPort); } userAgent = config.get(PARAM_USER_AGENT); if (StringUtil.isNullString(userAgent)) { userAgent = null; } else { log.debug("Setting User-Agent to " + userAgent); } }
public void destroy() { if (consumer != null) { consumer.shutdown(); logger.info( "consumer shutdown! topic={0},subExpression={1},group={2}", topic.getTopic(), subExpression, group); } }
/** * Returns the <tt>URL</tt> of the image corresponding to the given key. * * @param urlKey The identifier of the image in the resource properties file. * @return the <tt>URL</tt> of the image corresponding to the given key */ public URL getImageURL(String urlKey) { String path = getImagePath(urlKey); if (path == null || path.length() == 0) { if (logger.isInfoEnabled()) logger.info("Missing resource for key: " + urlKey); return null; } return getImageURLForPath(path); }
public DBTCPConnector(Mongo m, List<ServerAddress> all) throws MongoException { _mongo = m; _portHolder = new DBPortPool.Holder(m._options); _checkAddress(all); _allHosts = new ArrayList<ServerAddress>(all); // make a copy so it can't be modified _createLogger.info(all + " -> " + _curAddress); }
public h4Jmf(View view, String position) { super(); count++; logger.info("args constructor " + count); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // logger.info("view="+view+" position="+position); this.view = view; // position.equals(DockableWindowManager.FLOATING); // cnsl=new Console(100); h4JmfPlugin.cnsl.setPreferredSize(new Dimension(500, 200)); JScrollPane jscrllpn = new JScrollPane(h4JmfPlugin.cnsl); // jscrllpn.setPreferredSize(new Dimension(500,200)); // add(BorderLayout.SOUTH,jscrllpn); add(jscrllpn); if (h4JmfPlugin.playMP3 != null) { java.awt.Component cpc = h4JmfPlugin.playMP3.getControlPanelComponent(); // logger.info("cpc="+cpc); if (cpc != null) // after panel has been closed, new instance !! { cpc.setPreferredSize(new Dimension(500, 50)); this.add(cpc); } } this.setPreferredSize(new Dimension(500, 300)); // cnsl.append("begin"); // cnsl.append("SettingsDirectory="+jEdit.getSettingsDirectory()); h4JmfPlugin.cnsl.append("args constructor " + count); // EditBus.addToBus(this);//moved to notify /** * *********************** //check a few jmf-classes begin done in h4JmfPlugin Class tst=null; * try { tst=Class.forName("com.sun.media.codec.audio.mp3.JavaDecoder"); jmf_ok=true; * cnsl.append("jmf Java Media Framework seems to be installed."); } catch(Exception excptn) { * cnsl.append("trying presence of jmf"); cnsl.append(excptn); cnsl.append("jmf Java Media * Framework does not seem to be installed!"); cnsl.append("see README for more info"); } * //check a few jmf-classes end ** */ if (!h4JmfPlugin.jmf_ok) { h4JmfPlugin.cnsl.append("JMF Java Media Framework does not seem to be installed!"); h4JmfPlugin.cnsl.append("see README for more info"); } logger.info("constructor end"); } // constructor
public void registerListener(int id, MessageListener m) { HashSet listenerSet = (HashSet) idTable.get(new Integer(id)); if (listenerSet == null) { listenerSet = new HashSet(); idTable.put(new Integer(id), listenerSet); } listenerSet.add(m); log.info("New Listener for id=" + id); }
public ClientThread(Socket socket, History history, Users users) throws IOException { logger.warn("New client is trying to connect to the chat..."); logger.info("Assigning a socket to a new client..."); this.s = socket; logger.info("Getting the input stream..."); in = new DataInputStream(s.getInputStream()); logger.info("Getting the output stream..."); out = new DataOutputStream(s.getOutputStream()); this.users = users; users.addObserver(this); this.history = history; start(); logger.warn("Connection with new user is established."); }
/** * Initializes this network address manager service implementation and starts all * processes/threads associated with this address manager, such as a stun firewall/nat detector, * keep alive threads, binding lifetime discovery threads and etc. The method may also be used * after a call to stop() as a reinitialization technique. */ public void start() { // init stun String stunAddressStr = null; int port = -1; stunAddressStr = NetaddrActivator.getConfigurationService().getString(PROP_STUN_SERVER_ADDRESS); String portStr = NetaddrActivator.getConfigurationService().getString(PROP_STUN_SERVER_PORT); this.localHostFinderSocket = initRandomPortSocket(); if (stunAddressStr == null || portStr == null) { useStun = false; // we use the default stun server address only for chosing a public // route and not for stun queries. stunServerAddress = new StunAddress(DEFAULT_STUN_SERVER_ADDRESS, DEFAULT_STUN_SERVER_PORT); logger.info( "Stun server address(" + stunAddressStr + ")/port(" + portStr + ") not set (or invalid). Disabling STUN."); } else { try { port = Integer.valueOf(portStr).intValue(); } catch (NumberFormatException ex) { logger.error(portStr + " is not a valid port number. " + "Defaulting to 3478", ex); port = 3478; } stunServerAddress = new StunAddress(stunAddressStr, port); detector = new SimpleAddressDetector(stunServerAddress); if (logger.isDebugEnabled()) { logger.debug( "Created a STUN Address detector for the following " + "STUN server: " + stunAddressStr + ":" + port); } detector.start(); logger.debug("STUN server detector started;"); // make sure that someone doesn't set invalid stun address and port NetaddrActivator.getConfigurationService() .addVetoableChangeListener(PROP_STUN_SERVER_ADDRESS, this); NetaddrActivator.getConfigurationService() .addVetoableChangeListener(PROP_STUN_SERVER_PORT, this); // now start a thread query to the stun server and only set the // useStun flag to true if it succeeds. launchStunServerTest(); } }
/** * Logs the specified message and details. * * @param message the message to log * @param from the message sender * @param to the message addressee * @param status message status * @param sender determines whether we are the origin of this message. */ public void logMessage( SIPMessage message, String from, String to, String status, boolean sender) { if (!logger.isInfoEnabled()) return; String msgHeader; if (sender) msgHeader = "JAIN-SIP sent a message from=\""; else msgHeader = "JAIN-SIP received a message from=\""; if (logger.isInfoEnabled()) logger.info(msgHeader + from + "\" to=\"" + to + "\" (status: " + status + "):\n" + message); }
/** * Receives options requests and replies with an OK response containing methods that we support. * * @param requestEvent the incoming options request. * @return <tt>true</tt> if request has been successfully processed, <tt>false</tt> otherwise */ @Override public boolean processRequest(RequestEvent requestEvent) { Response optionsOK = null; try { optionsOK = provider.getMessageFactory().createResponse(Response.OK, requestEvent.getRequest()); // add to the allows header all methods that we support for (String method : provider.getSupportedMethods()) { // don't support REGISTERs if (!method.equals(Request.REGISTER)) optionsOK.addHeader(provider.getHeaderFactory().createAllowHeader(method)); } Iterable<String> knownEventsList = provider.getKnownEventsList(); synchronized (knownEventsList) { for (String event : knownEventsList) optionsOK.addHeader(provider.getHeaderFactory().createAllowEventsHeader(event)); } } catch (ParseException ex) { // What else could we do apart from logging? logger.warn("Failed to create an incoming OPTIONS request", ex); return false; } try { SipStackSharing.getOrCreateServerTransaction(requestEvent).sendResponse(optionsOK); } catch (TransactionUnavailableException ex) { // this means that we received an OPTIONS request outside the scope // of a transaction which could mean that someone is simply sending // us b****hit to keep a NAT connection alive, so let's not get too // excited. if (logger.isInfoEnabled()) logger.info("Failed to respond to an incoming " + "transactionless OPTIONS request"); if (logger.isTraceEnabled()) logger.trace("Exception was:", ex); return false; } catch (InvalidArgumentException ex) { // What else could we do apart from logging? logger.warn("Failed to send an incoming OPTIONS request", ex); return false; } catch (SipException ex) { // What else could we do apart from logging? logger.warn("Failed to send an incoming OPTIONS request", ex); return false; } return true; }
/** Start the JobTracker process, listen on the indicated port */ JobTracker(Configuration conf) throws IOException { // // Grab some static constants // maxCurrentTasks = conf.getInt("mapred.tasktracker.tasks.maximum", 2); RETIRE_JOB_INTERVAL = conf.getLong("mapred.jobtracker.retirejob.interval", 24 * 60 * 60 * 1000); RETIRE_JOB_CHECK_INTERVAL = conf.getLong("mapred.jobtracker.retirejob.check", 60 * 1000); TASK_ALLOC_EPSILON = conf.getFloat("mapred.jobtracker.taskalloc.loadbalance.epsilon", 0.2f); PAD_FRACTION = conf.getFloat("mapred.jobtracker.taskalloc.capacitypad", 0.1f); MIN_SLOTS_FOR_PADDING = 3 * maxCurrentTasks; // This is a directory of temporary submission files. We delete it // on startup, and can delete any files that we're done with this.conf = conf; JobConf jobConf = new JobConf(conf); this.systemDir = jobConf.getSystemDir(); this.fs = FileSystem.get(conf); FileUtil.fullyDelete(fs, systemDir); fs.mkdirs(systemDir); // Same with 'localDir' except it's always on the local disk. jobConf.deleteLocalFiles(SUBDIR); // Set ports, start RPC servers, etc. InetSocketAddress addr = getAddress(conf); this.localMachine = addr.getHostName(); this.port = addr.getPort(); this.interTrackerServer = RPC.getServer(this, addr.getPort(), 10, false, conf); this.interTrackerServer.start(); Properties p = System.getProperties(); for (Iterator it = p.keySet().iterator(); it.hasNext(); ) { String key = (String) it.next(); String val = (String) p.getProperty(key); LOG.info("Property '" + key + "' is " + val); } this.infoPort = conf.getInt("mapred.job.tracker.info.port", 50030); this.infoServer = new JobTrackerInfoServer(this, infoPort); this.infoServer.start(); this.startTime = System.currentTimeMillis(); new Thread(this.expireTrackers).start(); new Thread(this.retireJobs).start(); new Thread(this.initJobs).start(); }
/** * Accept and process a new TaskTracker profile. We might have known about the TaskTracker * previously, or it might be brand-new. All task-tracker structures have already been updated. * Just process the contained tasks and any jobs that might be affected. */ void updateTaskStatuses(TaskTrackerStatus status) { for (Iterator it = status.taskReports(); it.hasNext(); ) { TaskStatus report = (TaskStatus) it.next(); TaskInProgress tip = (TaskInProgress) taskidToTIPMap.get(report.getTaskId()); if (tip == null) { LOG.info( "Serious problem. While updating status, cannot find taskid " + report.getTaskId()); } else { JobInProgress job = tip.getJob(); job.updateTaskStatus(tip, report); if (report.getRunState() == TaskStatus.SUCCEEDED) { job.completedTask(tip, report.getTaskId()); } else if (report.getRunState() == TaskStatus.FAILED) { // Tell the job to fail the relevant task job.failedTask(tip, report.getTaskId(), status.getTrackerName()); } } } }
/** * Parses the given http response. * * @param response the http response to parse * @return the new account */ private NewAccount parseHttpResponse(String response) { NewAccount newAccount = null; try { JSONObject jsonObject = (JSONObject) JSONValue.parseWithException(response); boolean isSuccess = (Boolean) jsonObject.get("success"); if (isSuccess) { newAccount = new NewAccount( (String) jsonObject.get("sip_address"), passField.getPassword(), null, (String) jsonObject.get("outbound_proxy")); String xcapRoot = (String) jsonObject.get("xcap_root"); // as sip2sip adds @sip2sip.info at the end of the // xcap_uri but doesn't report it in resullt after // creating account, we add it String domain = null; int delimIndex = newAccount.getUserName().indexOf("@"); if (delimIndex != -1) { domain = newAccount.getUserName().substring(delimIndex); } if (domain != null) { if (xcapRoot.endsWith("/")) xcapRoot = xcapRoot.substring(0, xcapRoot.length() - 1) + domain; else xcapRoot += domain; } newAccount.setXcapRoot(xcapRoot); } else { showErrorMessage((String) jsonObject.get("error_message")); } } catch (Throwable e1) { if (logger.isInfoEnabled()) logger.info("Failed Json parsing.", e1); } return newAccount; }
private void _pickCurrent() throws MongoException { if (_allHosts == null) throw new MongoException( "got master/slave issue but not in master/slave mode on the client side"); synchronized (_allHosts) { Collections.shuffle(_allHosts); for (int i = 0; i < _allHosts.size(); i++) { ServerAddress a = _allHosts.get(i); if (a == _curAddress) continue; if (_curAddress != null) { _logger.info("switching from [" + _curAddress + "] to [" + a + "]"); } _set(a); return; } } throw new MongoException("couldn't find a new host to swtich too"); }
public void run() { try { prepareClient(); logger.info("Starting normal session with " + getClientName()); while (true) { this.receive(); } } catch (IOException ioe) { logger.warn("Client " + this + " has been disconnected."); this.setDisabled(true); users.remove(this); } finally { try { if (s != null && !s.isClosed()) { s.close(); logger.warn("Socket with " + this + " has been closed."); } } catch (IOException ioe) { logger.error("Socket has not been closed.", ioe); } } }
/////////////////////////////////////////////////////// // Maintain lookup tables; called by JobInProgress // and TaskInProgress /////////////////////////////////////////////////////// void createTaskEntry(String taskid, String taskTracker, TaskInProgress tip) { LOG.info( "Adding task '" + taskid + "' to tip " + tip.getTIPId() + ", for tracker '" + taskTracker + "'"); // taskid --> tracker taskidToTrackerMap.put(taskid, taskTracker); // tracker --> taskid TreeSet taskset = (TreeSet) trackerToTaskMap.get(taskTracker); if (taskset == null) { taskset = new TreeSet(); trackerToTaskMap.put(taskTracker, taskset); } taskset.add(taskid); // taskid --> TIP taskidToTIPMap.put(taskid, tip); }
private void prepareClient() throws IOException { logger.info("Waiting for client's name"); Message mes = Operations.receive(in); setClientName((String) mes.getValue()); logger.info("Username for " + s.getInetAddress() + " received: " + userName); users.add(this); logger.info("User " + getClientName() + " has been added to the userlist."); messages = new Messages(); logger.info("Message list created"); if (!history.containsKey(userName)) { history.put(userName, messages); } else { messages = history.get(userName); } messages.addObserver(this); logger.info("Message list assigned to history"); logger.info("Sending the list of users."); Operations.sendUserNamesList(users.getUserNames(), out); logger.info("Userlist has been sent"); }
public void init() throws MQClientException { nameServer = PropertyFileUtil.get("rocketmq.namesrv.domain"); if (StringUtils.isBlank(nameServer)) { logger.warn("【MQ init】property rocketmq.namesrv.domain not found"); return; } if ("localTest".equals(nameServer)) { logger.warn("【MQ init】localTest"); return; } if (StringUtils.isBlank(System.getProperty("rocketmq.namesrv.domain"))) { System.setProperty("rocketmq.namesrv.domain", nameServer); } topicType = getTopic(); topic = RocketMqUtils.getTopic(topicType); if (StringUtils.isBlank(group)) { group = "S_" + topic.getTopic() + "_" + topic.getTags(); } consumer = new DefaultMQPushConsumer(group); consumer.setNamesrvAddr(nameServer); consumer.setMessageModel(getMessageModel()); consumer.setConsumeThreadMin(minConsumeThread); consumer.setConsumeThreadMax(maxConsumeThread); // 可以不设置 设置后可以起多个 消费端 try { consumer.setInstanceName("DEFAULT_CONSUMER-" + InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException e) { logger.error("getHostName error", e); } // 设置订阅的topic 设置订阅过滤表达式 if (StringUtils.isBlank(subExpression)) { subExpression = topic.getTags(); consumer.subscribe(topic.getTopic(), subExpression); } else { consumer.subscribe(topic.getTopic(), subExpression); } try { consumer.registerMessageListener(this); consumer.start(); } catch (MQClientException e) { logger.error( "consumer start error!topic={},subExpression={},group={}", topic.getTopic(), subExpression, group, e); } logger.info( "consumer start! topic={},subExpression={},group={}", topic.getTopic(), subExpression, group); }
/** * Gathers UPnP candidates for all host <tt>Candidate</tt>s that are already present in the * specified <tt>component</tt>. This method relies on the specified <tt>component</tt> to already * contain all its host candidates so that it would resolve them. * * @param component the {@link Component} that we'd like to gather candidate UPnP * <tt>Candidate</tt>s for * @return the <tt>LocalCandidate</tt>s gathered by this <tt>CandidateHarvester</tt> */ public synchronized Collection<LocalCandidate> harvest(Component component) { Collection<LocalCandidate> candidates = new HashSet<>(); int retries = 0; logger.fine("Begin UPnP harvesting"); try { if (device == null) { // do it only once if (finishThreads == 0) { try { UPNPThread wanIPThread = new UPNPThread(stIP); UPNPThread wanPPPThread = new UPNPThread(stPPP); wanIPThread.start(); wanPPPThread.start(); synchronized (rootSync) { while (finishThreads != 2) { rootSync.wait(); } } if (wanIPThread.getDevice() != null) { device = wanIPThread.getDevice(); } else if (wanPPPThread.getDevice() != null) { device = wanPPPThread.getDevice(); } } catch (Throwable e) { logger.info("UPnP discovery failed: " + e); } } if (device == null) return candidates; } InetAddress localAddress = device.getLocalAddress(); String externalIPAddress = device.getExternalIPAddress(); PortMappingEntry portMapping = new PortMappingEntry(); IceSocketWrapper socket = new IceUdpSocketWrapper(new MultiplexingDatagramSocket(0, localAddress)); int port = socket.getLocalPort(); int externalPort = socket.getLocalPort(); while (retries < MAX_RETRIES) { if (!device.getSpecificPortMappingEntry(port, "UDP", portMapping)) { if (device.addPortMapping( externalPort, port, localAddress.getHostAddress(), "UDP", "ice4j.org: " + port)) { List<LocalCandidate> cands = createUPNPCandidate(socket, externalIPAddress, externalPort, component, device); logger.info("Add UPnP port mapping: " + externalIPAddress + " " + externalPort); // we have to add the UPNPCandidate and also the base. // if we don't add the base, we won't be able to add // peer reflexive candidate if someone contact us on the // UPNPCandidate for (LocalCandidate cand : cands) { // try to add the candidate to the component and then // only add it to the harvest not redundant if (component.addLocalCandidate(cand)) { candidates.add(cand); } } break; } else { port++; } } else { port++; } retries++; } } catch (Throwable e) { logger.info("Exception while gathering UPnP candidates: " + e); } return candidates; }
/** * Log an exception. * * @param ex the exception that we are to log. */ public void logException(Throwable ex) { logger.warn("Exception in the JAIN-SIP stack: " + ex.getMessage()); if (logger.isInfoEnabled()) logger.info("JAIN-SIP exception stack trace is", ex); }
public void receive() throws IOException { Message message = Operations.receive(in); logger.info("New message received."); processMessage(message); }
/** * Creates this account on the server. * * @return the created account */ public NewAccount createAccount() { // Check if the two passwords match. String pass1 = new String(passField.getPassword()); String pass2 = new String(retypePassField.getPassword()); if (!pass1.equals(pass2)) { showErrorMessage( IppiAccRegWizzActivator.getResources() .getI18NString("plugin.sipaccregwizz.NOT_SAME_PASSWORD")); return null; } NewAccount newAccount = null; try { StringBuilder registerLinkBuilder = new StringBuilder(registerLink); registerLinkBuilder .append(URLEncoder.encode("email", "UTF-8")) .append("=") .append(URLEncoder.encode(emailField.getText(), "UTF-8")) .append("&") .append(URLEncoder.encode("password", "UTF-8")) .append("=") .append(URLEncoder.encode(new String(passField.getPassword()), "UTF-8")) .append("&") .append(URLEncoder.encode("display_name", "UTF-8")) .append("=") .append(URLEncoder.encode(displayNameField.getText(), "UTF-8")) .append("&") .append(URLEncoder.encode("username", "UTF-8")) .append("=") .append(URLEncoder.encode(usernameField.getText(), "UTF-8")) .append("&") .append(URLEncoder.encode("user_agent", "UTF-8")) .append("=") .append(URLEncoder.encode("sip-communicator.org", "UTF-8")); URL url = new URL(registerLinkBuilder.toString()); URLConnection conn = url.openConnection(); // If this is not an http connection we have nothing to do here. if (!(conn instanceof HttpURLConnection)) { return null; } HttpURLConnection httpConn = (HttpURLConnection) conn; int responseCode = httpConn.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { // Read all the text returned by the server BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String str; StringBuffer stringBuffer = new StringBuffer(); while ((str = in.readLine()) != null) { stringBuffer.append(str); } if (logger.isInfoEnabled()) logger.info("JSON response to create account request: " + stringBuffer.toString()); newAccount = parseHttpResponse(stringBuffer.toString()); } } catch (MalformedURLException e1) { if (logger.isInfoEnabled()) logger.info("Failed to create URL with string: " + registerLink, e1); } catch (IOException e1) { if (logger.isInfoEnabled()) logger.info("Failed to open connection.", e1); } return newAccount; }
public DrainConnector(int p_spAddr, MoteIF p_moteIF) { spAddr = p_spAddr; moteIF = p_moteIF; moteIF.registerListener(new DrainMsg(), this); log.info("Started myAddr = " + spAddr + ", listening for DrainMsg"); }