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
/** * Reads a base class overrride from a resource file * * @param binaryClassName * @param fileName */ private void registerBaseClassOverride(String binaryClassName, String fileName) { try { Method mDefineClass = ClassLoader.class.getDeclaredMethod( "defineClass", String.class, byte[].class, int.class, int.class); mDefineClass.setAccessible(true); InputStream resourceInputStream = LiteLoader.class.getResourceAsStream("/classes/" + fileName + ".bin"); if (resourceInputStream != null) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); for (int readBytes = resourceInputStream.read(); readBytes >= 0; readBytes = resourceInputStream.read()) { outputStream.write(readBytes); } byte[] data = outputStream.toByteArray(); outputStream.close(); resourceInputStream.close(); logger.info("Defining class override for " + binaryClassName); mDefineClass.invoke( Minecraft.class.getClassLoader(), binaryClassName, data, 0, data.length); } else { logger.info("Error defining class override for " + binaryClassName + ", file not found"); } } catch (Throwable th) { logger.log(Level.WARNING, "Error defining class override for " + binaryClassName, th); } }
/** 基类实现消息监听接口,加上打印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); } }
/** * Takes as input a GnuPlot script file path and executes this script. inside the script the user * can plot to screen, pause and then print to a post script file. * * @param args args[0] should be the path to the GnuPlot script file relative to the Simulator * directory e.g. ./inputFiles/100C_20P_centralised/Gnuplot.gnu * <p>Example Script file GnuPlot.gnu: * <p>set xlabel "Lateral Displacement"; set ylabel "Contra-Lateral Displacement"; set zlabel * "Amplitude" set parametric set isosamples 75,75 set contour base set cntrparam level * incremental -1, 0.2, 10 set clabel '%4.2f' set contour surface set contour base; set * nosurface set surface; set view 20,60 set view 60,30 set hidden3d splot u,v,sin(u)*cos(v) * title "Standing Waves" set size 1.0, 0.6 set terminal postscript portrait enhanced color * dashed lw 1 "Helvetica" 14 set output 'tempoutput/my-plot.ps' replot set terminal x11 set * size 1,1 #pause 5 */ public static void gnuplot(String[] args) { logger.info("gnuplot called on scriptfile: " + args[0]); // get a Runtime object Runtime r = Runtime.getRuntime(); try { // start the process: gnuplot String exe = "wgnuplot " + args[0]; // String exe = "C:/Program Files/gnuplot/bin/wgnuplot " + args[0]; logger.info(exe); Process p = r.exec(exe); // any error message? StreamGobbler errorGobbler = new StreamGobbler(p.getErrorStream(), "ERR"); // any output? StreamGobbler outputGobbler = new StreamGobbler(p.getInputStream(), "OUT"); // kick them off errorGobbler.start(); outputGobbler.start(); // any error??? int exitVal = p.waitFor(); logger.error("ExitValue: " + exitVal); } catch (Exception e) { logger.fatal("Error Executing gnuplot: " + args[0] + " - ", e); } }
private void initLoader() { if (loaderStartupDone) return; loaderStartupDone = true; // Set up base class overrides prepareClassOverrides(); // Set up loader, initialises any reflection methods needed if (prepareLoader()) { logger.info("LiteLoader " + LOADER_VERSION + " starting up..."); logger.info( String.format("Java reports OS=\"%s\"", System.getProperty("os.name").toLowerCase())); // Examines the class path and mods folder and locates loadable mods prepareMods(); // Initialises enumerated mods initMods(); // Initialises the required hooks for loaded mods initHooks(); loaderStartupComplete = true; } }
public static void closeConnection() { if (twitter != null) { Logger.info("Closing down Twitter stream..."); twitter.cleanUp(); if (esClient != null) esClient.close(); } else { Logger.info("No twitter stream found"); } }
public void count() { TIntIntHashMap docCounts = new TIntIntHashMap(); int index = 0; if (instances.size() == 0) { logger.info("Instance list is empty"); return; } if (instances.get(0).getData() instanceof FeatureSequence) { for (Instance instance : instances) { FeatureSequence features = (FeatureSequence) instance.getData(); for (int i = 0; i < features.getLength(); i++) { docCounts.adjustOrPutValue(features.getIndexAtPosition(i), 1, 1); } int[] keys = docCounts.keys(); for (int i = 0; i < keys.length - 1; i++) { int feature = keys[i]; featureCounts[feature] += docCounts.get(feature); documentFrequencies[feature]++; } docCounts = new TIntIntHashMap(); index++; if (index % 1000 == 0) { System.err.println(index); } } } else if (instances.get(0).getData() instanceof FeatureVector) { for (Instance instance : instances) { FeatureVector features = (FeatureVector) instance.getData(); for (int location = 0; location < features.numLocations(); location++) { int feature = features.indexAtLocation(location); double value = features.valueAtLocation(location); documentFrequencies[feature]++; featureCounts[feature] += value; } index++; if (index % 1000 == 0) { System.err.println(index); } } } else { logger.info("Unsupported data class: " + instances.get(0).getData().getClass().getName()); } }
// Gets a property. static String getStringProperty(String propName) { String temp = getConfigValue(propName); String result = ""; if (temp != null) { result = temp; Logger.info("{DB}-" + propName + ":" + result); } else { result = properties.getProperty(propName); Logger.info("{FILE}-" + propName + ":" + result); } return result; }
// Gets a property and converts it into integer. static int getIntProperty(String propName, int defaultValue) { String temp = getConfigValue(propName); int result = defaultValue; if (temp != null) { result = Integer.parseInt(temp); Logger.info("{DB}-" + propName + ":" + result); } else { result = Integer.parseInt(properties.getProperty(propName, Integer.toString(defaultValue)).trim()); Logger.info("{FILE}-" + propName + ":" + result); } return result; }
public TweetListener(List<String> terms, Client esClient, String esIndex, String esType) { this.terms = terms; this.esClient = esClient; StringBuilder query = new StringBuilder(); for (int i = 0; i < terms.size(); i++) { if (i > 0) query.append("|"); // query.append("(").append(Pattern.quote(terms.get(i))).append(")"); // query.append("(").append(terms.get(i)).append(")"); query.append(terms.get(i)); } Logger.info("Query match pattern: " + query.toString()); this.matchPattern = Pattern.compile(query.toString(), Pattern.CASE_INSENSITIVE); Logger.info("Query match pattern: " + matchPattern.toString()); }
// Gets a property and converts it into byte. static byte getByteProperty(String propName, byte defaultValue) { String temp = getConfigValue(propName); byte result = defaultValue; if (temp != null) { result = Byte.parseByte(temp); Logger.info("{DB}-" + propName + ":" + result); } else { result = Byte.parseByte(properties.getProperty(propName, Byte.toString(defaultValue)).trim()); Logger.info("{FILE}-" + propName + ":" + result); } return result; }
// 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
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; } }
private static void startStream(List<String> terms) throws TwitterException { if (twitter != null) { twitter.cleanUp(); } if (esClient != null) { esClient.close(); esClient = null; } play.Configuration pconf = Play.application().configuration(); String elasticSearchCluster = pconf.getString("tweet.elasticsearch.cluster.name"); if (elasticSearchCluster != null) { Logger.info("Configuring ElasticSearch..."); Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", elasticSearchCluster).build(); esClient = new TransportClient(settings) .addTransportAddress( new InetSocketTransportAddress( pconf.getString("tweet.elasticsearch.transport.host"), pconf.getInt("tweet.elasticsearch.transport.port"))); } else { esClient = null; } twitter4j.conf.Configuration tconf = Application.getTwitterConfiguration(); TwitterStreamFactory tf = new TwitterStreamFactory(tconf); twitter = tf.getInstance(); StatusListener l = new TweetListener( terms, esClient, pconf.getString("tweet.elasticsearch.index"), pconf.getString("tweet.elasticsearch.type")); twitter.addListener(l); String[] tracks = new String[terms.size()]; StringBuffer termsString = new StringBuffer(); for (int i = 0; i < terms.size(); i++) { tracks[i] = terms.get(i); if (i != 0) termsString.append(","); termsString.append(terms.get(i)); } FilterQuery q = new FilterQuery().track(tracks); twitter.filter(q); Logger.info("Starting listening for tweets using terms " + termsString.toString() + "..."); }
public static Result start() { java.util.Map<String, String[]> map = request().body().asFormUrlEncoded(); List<String> terms = new ArrayList<>(map.size()); for (int i = 0; i < map.size(); i++) { String key = "terms[" + i + "]"; if (map.containsKey(key)) { String[] values = map.get(key); if ((values != null) && (values.length >= 1)) { terms.add(values[0]); } } } StreamConfig config = getConfig(); config.putTerms(terms); config.update(); StringBuilder sb = new StringBuilder(); for (String t : terms) { sb.append(t); sb.append(", "); } sb.delete(sb.length() - 2, sb.length()); try { startStream(terms); flash("success", "Twitter stream started (" + sb.toString() + ")"); } catch (TwitterException e) { Logger.info("Error starting twitter stream", e); flash("error", "Error starting Twitter stream" + e.getMessage()); } return redirect(routes.Streams.listAll()); }
/** * Starts the configuration service * * @param bundleContext the <tt>BundleContext</tt> as provided by the OSGi framework. * @throws Exception if anything goes wrong */ public void start(BundleContext bundleContext) throws Exception { FileAccessService fas = ServiceUtils.getService(bundleContext, FileAccessService.class); if (fas != null) { File usePropFileConfig; try { usePropFileConfig = fas.getPrivatePersistentFile(".usepropfileconfig", FileCategory.PROFILE); } catch (Exception ise) { // There is somewhat of a chicken-and-egg dependency between // FileConfigurationServiceImpl and ConfigurationServiceImpl: // FileConfigurationServiceImpl throws IllegalStateException if // certain System properties are not set, // ConfigurationServiceImpl will make sure that these properties // are set but it will do that later. // A SecurityException is thrown when the destination // is not writable or we do not have access to that folder usePropFileConfig = null; } if (usePropFileConfig != null && usePropFileConfig.exists()) { logger.info("Using properties file configuration store."); this.cs = LibJitsi.getConfigurationService(); } } if (this.cs == null) { this.cs = new JdbcConfigService(fas); } bundleContext.registerService(ConfigurationService.class.getName(), this.cs, null); fixPermissions(this.cs); }
/** * Send Conference POST request to API endpoint which is used for allocating new conferences in * reservation system. * * @param ownerEmail email of new conference owner * @param mucRoomName full name of MUC room that is hosting the conference. * {room_name}@{muc.server.net} * @return <tt>ApiResult</tt> that contains system response. It will contain <tt>Conference</tt> * instance filled with data from the reservation system if everything goes OK. * @throws FaultTolerantRESTRequest.RetryExhaustedException When the number of retries to submit * the request for the conference data is reached * @throws UnsupportedEncodingException When the room data have the encoding that does not play * with UTF8 standard */ public ApiResult createNewConference(String ownerEmail, String mucRoomName) throws FaultTolerantRESTRequest.RetryExhaustedException, UnsupportedEncodingException { Conference conference = new Conference(mucRoomName, ownerEmail, new Date()); HttpPost post = new HttpPost(baseUrl + "/conference"); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1); Map<String, Object> jsonMap = conference.createJSonMap(); for (Map.Entry<String, Object> entry : jsonMap.entrySet()) { nameValuePairs.add(new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue()))); } post.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF8")); logger.info("Sending post: " + jsonMap); CreateConferenceResponseParser conferenceResponseParser = new CreateConferenceResponseParser(conference); FaultTolerantRESTRequest faultTolerantRESTRequest = new FaultTolerantRESTRequest(post, conferenceResponseParser, retriesCreate, httpClient); return faultTolerantRESTRequest.submit(); }
protected List<MappingWithDirection> findApplicable(MappingKey key) { ArrayList<MappingWithDirection> result = new ArrayList<MappingWithDirection>(); for (ParsedMapping pm : mappings) { if ((pm.mappingCase == null && key.mappingCase == null) ^ (pm.mappingCase != null && pm.mappingCase.equals(key.mappingCase))) { if (pm.sideA.isAssignableFrom(key.source) && pm.sideB.isAssignableFrom(key.target)) result.add(new MappingWithDirection(pm, true)); else if (pm.sideB.isAssignableFrom(key.source) && pm.sideA.isAssignableFrom(key.target)) result.add(new MappingWithDirection(pm, false)); } } if (!result.isEmpty()) { Collections.sort(result, new MappingComparator(key.target)); } else if (automappingEnabled) { logger.info( "Could not find applicable mappings between {} and {}. A mapping will be created using automapping facility", key.source.getName(), key.target.getName()); ParsedMapping pm = new Mapping(key.source, key.target, this).automap().parse(); logger.debug("Automatically created {}", pm); mappings.add(pm); result.add(new MappingWithDirection(pm, true)); } else logger.warn( "Could not find applicable mappings between {} and {}!", key.source.getName(), key.target.getName()); return result; }
/* * 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(); } }
public static void logm(String t, int lvl, String msg, Object o) { // System.out.println("LOG:" + t + ":" + lvl + ":" + msg + ":" + (o != null ? ser_json(o) : // "")); if (lvl <= LogLvlMax) { logger.info(t + ":" + lvl + ":" + msg + ":" + (o != null ? ser_json(o) : "")); } }
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); } }
private void handleException(Exception e) { if (INTERRUPTED_EXCEPTION_TYPES.contains(e.getClass())) { LOG.info("Changes feed was interrupted"); } else { LOG.error("Caught exception while listening to changes feed:", e); } }
public void destroy() { if (consumer != null) { consumer.shutdown(); logger.info( "consumer shutdown! topic={0},subExpression={1},group={2}", topic.getTopic(), subExpression, group); } }
public static void startConnection() { StreamConfig config = getConfig(); try { startStream(config.listTerms()); } catch (TwitterException e) { Logger.info("Error starting twitter stream", e); } }
private void deleteBlock(CachedUrl cu) throws IOException { log.info("deleting " + cu.getUrl()); CachedUrlSetSpec cuss = new SingleNodeCachedUrlSetSpec(cu.getUrl()); ArchivalUnit au = cu.getArchivalUnit(); CachedUrlSet cus = au.makeCachedUrlSet(cuss); NodeManager nm = au.getPlugin().getDaemon().getNodeManager(au); nm.deleteNode(cus); }
public static void LogMessage(String msg) { String log_row = "APP_MESSAGE:" + msg; try { logger.info(log_row); } catch (Exception ex) { System.out.println("MyLogger.Log():" + ex.getMessage()); } }
/** * 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 static void Log(String method_name, String msg) { String log_row = "APP_ERROR:" + " method=" + method_name + " error_message=" + msg; try { logger.info(log_row); } catch (Exception ex) { System.out.println("MyLogger.Log():" + ex.getMessage()); } }