List of usage examples for java.util.logging Level OFF
Level OFF
To view the source code for java.util.logging Level OFF.
Click Source Link
From source file:power.backend.InterpssFlowBackend.java
public boolean flowAnalysisIpssDataLoader(FlowNetwork net, String CaseName) { this.SfinaNet = net; IpssCorePlugin.init(Level.OFF); try {/*from w w w . jav a 2 s .c o m*/ switch (powerFlowType) { case AC: this.IpssNet = CorePluginObjFactory.getFileAdapter(IpssFileAdapter.FileFormat.IEEECDF).load( "/Users/Ben/Documents/Studium/COSS/SFINA/java/SFINA/configuration_files/case_files/ieee/" + CaseName + ".txt") .getAclfNet(); renameIpssObjects(); //setVoltZero(); LoadflowAlgorithm acAlgo = CoreObjectFactory.createLoadflowAlgorithm(IpssNet); acAlgo.loadflow(); String resultLoaded = AclfOut_BusStyle.lfResultsBusStyle(IpssNet, BusIdStyle.BusId_No).toString(); //System.out.println(resultLoaded); getIpssACResults(); break; case DC: this.IpssNet = CorePluginObjFactory.getFileAdapter(IpssFileAdapter.FileFormat.IEEECDF).load( "/Users/Ben/Documents/Studium/COSS/SFINA/java/SFINA/configuration_files/case_files/ieee/" + CaseName + ".txt") .getAclfNet(); renameIpssObjects(); DclfAlgorithm dcAlgo = DclfObjectFactory.createDclfAlgorithm(IpssNet); dcAlgo.calculateDclf(); String resultDC = DclfOutFunc.dclfResults(dcAlgo, false).toString(); // System.out.println(resultDC); getIpssDCResults(dcAlgo); break; default: logger.debug("Power flow type is not recognized."); } this.converged = IpssNet.isLfConverged(); } catch (ReferenceBusException rbe) { rbe.printStackTrace(); } catch (IpssNumericException ine) { ine.printStackTrace(); } catch (InterpssException ie) { ie.printStackTrace(); } return converged; }
From source file:jp.ikedam.jenkins.plugins.ldap_sasl.LdapTest.java
@Test @For(SearchUserDnResolver.class) public void testSearchUserDnResolver_Failure() { // No match//from w w w . j a v a 2 s .com { LdapSaslSecurityRealm target = new LdapSaslSecurityRealm( Arrays.asList(String.format("ldap://127.0.0.1:%d/", ldapPort)), "DIGEST-MD5", new SearchUserDnResolver("dc=example,dc=com", "cn=${uid}"), new NoGroupResolver(), 0, 3000); LdapUser user = (LdapUser) target.authenticate("test1", "password1"); assertNull("No match", user.getDn()); } // More than one match { LdapSaslSecurityRealm target = new LdapSaslSecurityRealm( Arrays.asList(String.format("ldap://127.0.0.1:%d/", ldapPort)), "DIGEST-MD5", new SearchUserDnResolver("dc=example,dc=com", "objectClass=inetOrgPerson"), new NoGroupResolver(), 0, 3000); LdapUser user = (LdapUser) target.authenticate("test1", "password1"); assertNull("More than one match", user.getDn()); } // Non exist DN(specified as a parameter) { Level level = Logger.getLogger(SearchUserDnResolver.class.getName()).getLevel(); try { // Suppress severe log Logger.getLogger(SearchUserDnResolver.class.getName()).setLevel(Level.OFF); LdapSaslSecurityRealm target = new LdapSaslSecurityRealm( Arrays.asList(String.format("ldap://127.0.0.1:%d/", ldapPort)), "DIGEST-MD5", new SearchUserDnResolver("dc=example,dc=jp", "uid=${uid}"), new NoGroupResolver(), 0, 3000); LdapUser user = (LdapUser) target.authenticate("test1", "password1"); assertNull("Non exist DN(specified as a parameter)", user.getDn()); } finally { Logger.getLogger(SearchUserDnResolver.class.getName()).setLevel(level); } } // Non exist DN(specified in URI) { Level level = Logger.getLogger(SearchUserDnResolver.class.getName()).getLevel(); try { // Suppress severe log Logger.getLogger(SearchUserDnResolver.class.getName()).setLevel(Level.OFF); LdapSaslSecurityRealm target = new LdapSaslSecurityRealm( Arrays.asList(String.format("ldap://127.0.0.1:%d/dc=example,dc=jp", ldapPort)), "DIGEST-MD5", new SearchUserDnResolver(null, "uid=${uid}"), new NoGroupResolver(), 0, 3000); LdapUser user = (LdapUser) target.authenticate("test1", "password1"); assertNull("Non exist DN(specified in URI)", user.getDn()); } finally { Logger.getLogger(SearchUserDnResolver.class.getName()).setLevel(level); } } // Invalid DN { Level level = Logger.getLogger(SearchUserDnResolver.class.getName()).getLevel(); try { // Suppress severe log Logger.getLogger(SearchUserDnResolver.class.getName()).setLevel(Level.OFF); LdapSaslSecurityRealm target = new LdapSaslSecurityRealm( Arrays.asList(String.format("ldap://127.0.0.1:%d/dc=example,dc=jp", ldapPort)), "DIGEST-MD5", new SearchUserDnResolver("hogehoge", "uid=${uid}"), new NoGroupResolver(), 0, 3000); LdapUser user = (LdapUser) target.authenticate("test1", "password1"); assertNull("Invalid DN", user.getDn()); } finally { Logger.getLogger(SearchUserDnResolver.class.getName()).setLevel(level); } } // No query(null) { LdapSaslSecurityRealm target = new LdapSaslSecurityRealm( Arrays.asList(String.format("ldap://127.0.0.1:%d/", ldapPort)), "DIGEST-MD5", new SearchUserDnResolver("dc=example,dc=com", null), new NoGroupResolver(), 0, 3000); LdapUser user = (LdapUser) target.authenticate("test1", "password1"); assertNull("No query(null)", user.getDn()); } // No query(empty) { LdapSaslSecurityRealm target = new LdapSaslSecurityRealm( Arrays.asList(String.format("ldap://127.0.0.1:%d/", ldapPort)), "DIGEST-MD5", new SearchUserDnResolver("dc=example,dc=com", " "), new NoGroupResolver(), 0, 3000); LdapUser user = (LdapUser) target.authenticate("test1", "password1"); assertNull("No query(empty)", user.getDn()); } // Bad query { Level level = Logger.getLogger(SearchUserDnResolver.class.getName()).getLevel(); try { // Suppress severe log Logger.getLogger(SearchUserDnResolver.class.getName()).setLevel(Level.OFF); LdapSaslSecurityRealm target = new LdapSaslSecurityRealm( Arrays.asList(String.format("ldap://127.0.0.1:%d/", ldapPort)), "DIGEST-MD5", new SearchUserDnResolver("dc=example,dc=com", "hogehoge"), new NoGroupResolver(), 0, 3000); LdapUser user = (LdapUser) target.authenticate("test1", "password1"); assertNull("Bad query", user.getDn()); } finally { Logger.getLogger(SearchUserDnResolver.class.getName()).setLevel(level); } } }
From source file:power.backend.InterpssFlowBackend.java
public void getIpssData(FlowNetwork net, String caseName) { this.SfinaNet = net; IpssCorePlugin.init(Level.OFF); try {/*from www . ja v a2s. com*/ this.IpssNet = CorePluginObjFactory.getFileAdapter(IpssFileAdapter.FileFormat.IEEECDF) .load("/Users/Ben/Documents/Studium/COSS/SFINA/java/SFINA/configuration_files/case_files/ieee/" + caseName + ".txt") .getAclfNet(); renameIpssObjects(); getIpssACResults(); } catch (InterpssException ie) { ie.printStackTrace(); } }
From source file:power.backend.InterpssFlowBackend.java
public void compareDataToCaseLoaded(FlowNetwork net, String CaseName) throws InterpssException { this.SfinaNet = net; IpssCorePlugin.init(Level.OFF); buildIpssNet();//from w w w. j a v a2 s . c o m AclfNetwork caseNet = CorePluginObjFactory.getFileAdapter(IpssFileAdapter.FileFormat.IEEECDF) .load("/Users/Ben/Documents/Studium/COSS/SFINA/java/SFINA/configuration_files/case_files/ieee/" + CaseName + ".txt") .getAclfNet(); int j = 1; for (AclfBus bus : caseNet.getBusList()) { bus.setId(String.valueOf(j++)); } j = 1; for (AclfBranch branch : caseNet.getBranchList()) { branch.setId(String.valueOf(j++)); //branch.setName(String.valueOf(j++)); } //System.out.println(SfinaNet.getNode("9").getProperty(PowerNodeState.SHUNT_CONDUCT) + "," + SfinaNet.getNode("9").getProperty(PowerNodeState.SHUNT_SUSCEPT)); //System.out.println(caseNet.getBus("Bus9").getShuntY()); int col = 20; String busHeadFormatter = "%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s\n"; System.out.println("--- Buses Data Difference----"); System.out.format(busHeadFormatter, "ID", "Voltage Mag", "Voltage Ang", "Base Voltage", "LoadP", "LoadQ", "LoadCode", "GenP", "GenQ", "GenCode", "ShuntY", "BaseMVA", "BaseKVA", "GenPartFactor", "DesiredVoltMag", "ExpectedLoadP", "LoadDistFactor"); String busFormatter = "%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s\n"; // for (int i=1; i < caseNet.getNoBus()+1; i++){ // AclfBus busLoaded = caseNet.getBus("" + i); // System.out.println(caseNet.getBusList()); // AclfBus busDirect = IpssNet.getBus("" + i); // System.out.println(IpssNet.getBusList()); // System.out.format(busFormatter, i, getRelative(busLoaded.getVoltageMag(),busDirect.getVoltageMag()), getRelative(busLoaded.getVoltageAng(), busDirect.getVoltageAng()), getRelative(busLoaded.getBaseVoltage(), busDirect.getBaseVoltage()), getRelative(busLoaded.getLoadP(), busDirect.getLoadP()), getRelative(busLoaded.getLoadQ(), busDirect.getLoadQ()), busLoaded.getLoadCode() + " vs " + busDirect.getLoadCode(), getRelative(busLoaded.getGenP(), busDirect.getGenP()), getRelative(busLoaded.getGenQ(), busDirect.getGenQ()), busLoaded.getGenCode() + " vs " + busDirect.getGenCode(), "(" + getRelative(busLoaded.getShuntY().getReal(),busDirect.getShuntY().getReal()) + " , " + getRelative(busLoaded.getShuntY().getImaginary(),busDirect.getShuntY().getImaginary()) + ")", getRelative(caseNet.getBaseMva(),IpssNet.getBaseMva()), getRelative(caseNet.getBaseKva(), IpssNet.getBaseKva()), getRelative(busLoaded.getGenPartFactor(), busDirect.getGenPartFactor()), getRelative(busLoaded.getDesiredVoltMag(), busDirect.getDesiredVoltMag()), getRelative(busLoaded.getExpLoadP(), busDirect.getExpLoadP()), getRelative(busLoaded.getLoadDistFactor(), busDirect.getLoadDistFactor())); // } for (int i = 1; i < caseNet.getNoBus() + 1; i++) { AclfBus busLoaded = caseNet.getBusList().get(i - 1); AclfBus busDirect = IpssNet.getBusList().get(i - 1); System.out.format(busFormatter, busLoaded.getId(), getRelative(busLoaded.getVoltageMag(), busDirect.getVoltageMag()), getRelative(busLoaded.getVoltageAng(), busDirect.getVoltageAng()), getRelative(busLoaded.getBaseVoltage(), busDirect.getBaseVoltage()), getRelative(busLoaded.getLoadP(), busDirect.getLoadP()), getRelative(busLoaded.getLoadQ(), busDirect.getLoadQ()), compBool(busLoaded.getLoadCode(), busDirect.getLoadCode()), getRelative(busLoaded.getGenP(), busDirect.getGenP()), getRelative(busLoaded.getGenQ(), busDirect.getGenQ()), compBool(busLoaded.getGenCode(), busDirect.getGenCode()), "(" + getRelative(busLoaded.getShuntY().getReal(), busDirect.getShuntY().getReal()) + " , " + getRelative(busLoaded.getShuntY().getImaginary(), busDirect.getShuntY().getImaginary()) + ")", getRelative(caseNet.getBaseMva(), IpssNet.getBaseMva()), getRelative(caseNet.getBaseKva(), IpssNet.getBaseKva()), getRelative(busLoaded.getGenPartFactor(), busDirect.getGenPartFactor()), getRelative(busLoaded.getDesiredVoltMag(), busDirect.getDesiredVoltMag()), getRelative(busLoaded.getExpLoadP(), busDirect.getExpLoadP()), getRelative(busLoaded.getLoadDistFactor(), busDirect.getLoadDistFactor())); } String braHeadFormatter = "%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s\n"; System.out.println("--- Branches Data Difference----"); System.out.format(braHeadFormatter, "ID", "fromBus", "toBus", "Z", "HShuntY", "Y", "FromTurnRatio", "ToTurnRatio", "FromPSXfrAngle", "ToPSXfrAngle"); String braFormatter = "%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s%" + col + "s\n"; for (int i = 1; i < caseNet.getNoBranch() + 1; i++) { AclfBranch branchLoaded = caseNet.getBranchList().get(i - 1); AclfBranch branchDirect = IpssNet.getBranchList().get(i - 1); System.out.format(braFormatter, i, compBool(branchLoaded.getFromBus().getId(), branchDirect.getFromBus().getId()), compBool(branchLoaded.getToBus().getId(), branchDirect.getToBus().getId()), "(" + getRelative(branchLoaded.getZ().getReal(), branchDirect.getZ().getReal()) + " , " + getRelative(branchLoaded.getZ().getImaginary(), branchDirect.getZ().getImaginary()) + ")", "(" + getRelative(branchLoaded.getHShuntY().getReal(), branchDirect.getHShuntY().getReal()) + " , " + getRelative(branchLoaded.getHShuntY().getImaginary(), branchDirect.getHShuntY().getImaginary()) + ")", "(" + getRelative(branchLoaded.getY().getReal(), branchDirect.getY().getReal()) + " , " + getRelative(branchLoaded.getY().getImaginary(), branchDirect.getY().getImaginary()) + ")", compBool(branchLoaded.getFromTurnRatio(), branchDirect.getFromTurnRatio()), compBool(branchLoaded.getToTurnRatio(), branchDirect.getToTurnRatio()), getRelative(branchLoaded.getFromPSXfrAngle(), branchDirect.getFromPSXfrAngle()), getRelative(branchLoaded.getToPSXfrAngle(), branchDirect.getToPSXfrAngle())); } LoadflowAlgorithm acAlgoLoaded = CoreObjectFactory.createLoadflowAlgorithm(caseNet); LoadflowAlgorithm acAlgoDirect = CoreObjectFactory.createLoadflowAlgorithm(IpssNet); //System.out.println(acAlgoLoaded.toString()); //System.out.println(acAlgoDirect.toString()); }
From source file:CSSDFarm.UserInterface.java
/** * Configure JxBrowser to be displayed. Load map.html from file to string data, load * this data into JxBrowser and add the browser to the panel. *//*from w w w . j av a 2s . co m*/ public void displayHeatmap() { LoggerProvider.getChromiumProcessLogger().setLevel(Level.OFF); LoggerProvider.getIPCLogger().setLevel(Level.OFF); LoggerProvider.getBrowserLogger().setLevel(Level.OFF); BrowserView view = new BrowserView(browser); JPanel toolBar = new JPanel(); Dimension dimension = panelHeatmap.getSize(); JInternalFrame internalFrame = new JInternalFrame(); internalFrame.add(view, BorderLayout.CENTER); internalFrame.add(toolBar, BorderLayout.NORTH); internalFrame.setSize(dimension); internalFrame.setLocation(0, 0); internalFrame.setBorder(null); internalFrame.setVisible(true); ((javax.swing.plaf.basic.BasicInternalFrameUI) internalFrame.getUI()).setNorthPane(null); URL url = getClass().getResource("map.html"); File html = new File(url.getPath()); String htmlString = null; try { htmlString = FileUtils.readFileToString(html); } catch (IOException ex) { Logger.getLogger(UserInterface.class.getName()).log(Level.SEVERE, null, ex); } browser.loadHTML(htmlString); panelHeatmap.add(internalFrame); }
From source file:fr.msch.wissl.server.Library.java
private static void stfuLog4j() { Properties props = new Properties(); // props.setProperty("org.jaudiotagger.level", // Level.WARNING.toString()); props.setProperty(".level", Level.OFF.toString()); // props.setProperty("handlers", // "java.util.logging.ConsoleHandler,java.util.logging.FileHandler"); try {//ww w . j a va 2s . com ByteArrayOutputStream baos = new ByteArrayOutputStream(); props.store(baos, null); byte[] data = baos.toByteArray(); baos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(data); LogManager.getLogManager().readConfiguration(bais); } catch (IOException e) { e.printStackTrace(); } }
From source file:net.rptools.maptool.launcher.MapToolLauncher.java
private JPanel buildTroubleshootingPanel() { final JPanel p = new JPanel(); p.setLayout(new BorderLayout()); ActionListener levelChange = new ActionListener() { @Override//from ww w.j a va2s. co m public void actionPerformed(ActionEvent e) { Level x = Level.parse(e.getActionCommand()); if (Level.OFF.equals(x) || Level.INFO.equals(x) || Level.WARNING.equals(x) || Level.SEVERE.equals(x)) log.setLevel(x); } }; JPanel logPanel = new JPanel(); logPanel.setLayout(new GridLayout(0, 1)); logPanel.setBorder(new TitledBorder(new LineBorder(Color.BLACK), CopiedFromOtherJars.getText("msg.logDetailPanel.border"))); //$NON-NLS-1$ logPanel.setAlignmentX(Component.LEFT_ALIGNMENT); ButtonGroup logGroup = new ButtonGroup(); for (Level type : new Level[] { Level.OFF, Level.INFO, Level.WARNING, Level.SEVERE }) { JRadioButton jrb = new JRadioButton(type.toString()); jrb.setActionCommand(type.toString()); jrb.addActionListener(levelChange); jrb.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), jrb.getBorder())); logPanel.add(jrb); logGroup.add(jrb); if (type == Level.WARNING) { jrb.setSelected(true); log.setLevel(type); } } jcbEnableAssertions.setAlignmentX(Component.LEFT_ALIGNMENT); jcbEnableAssertions.setText(CopiedFromOtherJars.getText("msg.info.enableAssertions")); //$NON-NLS-1$ jcbEnableAssertions.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.enableAssertions")); //$NON-NLS-1$ jcbEnableAssertions.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (!extraArgs.contains(ASSERTIONS_OPTION)) { extraArgs = (ASSERTIONS_OPTION + " " + extraArgs); //$NON-NLS-1$ } } else if (e.getStateChange() == ItemEvent.DESELECTED) { extraArgs = extraArgs.replace(ASSERTIONS_OPTION, ""); //$NON-NLS-1$ } extraArgs = extraArgs.trim(); jtfArgs.setText(extraArgs); updateCommand(); } }); p.add(logPanel, BorderLayout.NORTH); Box other = new Box(BoxLayout.PAGE_AXIS); other.add(jcbEnableAssertions); other.add(Box.createVerticalGlue()); p.add(other, BorderLayout.CENTER); return p; }
From source file:org.eclipse.birt.report.engine.api.ReportRunner.java
/** * new a EngineConfig and config it with user's setting * /* www . j av a 2s. co m*/ */ protected EngineConfig createEngineConfig() { EngineConfig config = new EngineConfig(); String resourcePath = (String) params.get("resourceDir"); if (resourcePath != null) config.setResourcePath(resourcePath.trim()); String tempDir = (String) params.get("tempDir"); if (tempDir != null) config.setTempDir(tempDir.trim()); String logDir = (String) params.get("logDir"); String logLevel = (String) params.get("logLevel"); Level level = null; if (logLevel != null) { logLevel = logLevel.trim(); if ("all".equalsIgnoreCase(logLevel)) { level = Level.ALL; } else if ("config".equalsIgnoreCase(logLevel)) { level = Level.CONFIG; } else if ("fine".equalsIgnoreCase(logLevel)) { level = Level.FINE; } else if ("finer".equalsIgnoreCase(logLevel)) { level = Level.FINER; } else if ("finest".equalsIgnoreCase(logLevel)) { level = Level.FINEST; } else if ("info".equalsIgnoreCase(logLevel)) { level = Level.INFO; } else if ("off".equalsIgnoreCase(logLevel)) { level = Level.OFF; } else if ("severe".equalsIgnoreCase(logLevel)) { level = Level.SEVERE; } else if ("warning".equalsIgnoreCase(logLevel)) { level = Level.WARNING; } } String logD = (logDir == null) ? config.getLogDirectory() : logDir; Level logL = (level == null) ? config.getLogLevel() : level; config.setLogConfig(logD, logL); String logFile = (String) params.get("logFile"); if (logFile != null) config.setLogFile(logFile.trim()); String scripts = (String) params.get("scriptPath"); HashMap map = new HashMap(); map.put(EngineConstants.PROJECT_CLASSPATH_KEY, scripts); config.setAppContext(map); return config; }
From source file:org.quickserver.net.qsadmin.CommandHandler.java
public void handleCommand(ClientHandler handler, String command) throws SocketTimeoutException, IOException { if (command == null || command.trim().equals("")) { handler.sendClientMsg("-ERR No command"); return;//from ww w .j a va2s . c o m } //v1.2 - plugin if (plugin != null && plugin.handleCommand(handler, command)) { logger.fine("Handled by plugin."); return; } QSAdminServer adminServer = (QSAdminServer) handler.getServer().getStoreObjects()[2]; StringTokenizer st = new StringTokenizer(command, " "); String cmd = null; cmd = st.nextToken().toLowerCase(); String param[] = new String[st.countTokens()]; QuickServer target = null; for (int i = 0; st.hasMoreTokens(); i++) { param[i] = st.nextToken(); } if (command.equals("start console")) { /*v1.4.5*/ QSAdminShell.getInstance((QuickServer) handler.getServer().getStoreObjects()[0], null); handler.sendClientMsg("+OK QSAdminShell is started."); return; } else if (command.equals("stop console")) { /*v1.4.5*/ QSAdminShell shell = QSAdminShell.getInstance(null, null); if (shell != null) { try { shell.stopShell(); } catch (Exception err) { handler.sendClientMsg("-ERR Error stopping QSAdminShell: " + err); } handler.sendClientMsg("+OK QSAdminShell is stopped."); } else { handler.sendClientMsg("-ERR QSAdminShell is not running."); } return; } else if (cmd.equals("jvm")) {/*2.0.0*/ /* jvm dumpHeap jvm dumpJmapHisto file jvm dumpJmapHisto log jvm threadDump file jvm threadDump log jvm dumpJStack file jvm dumpJStack log */ if (param.length == 0) { handler.sendClientMsg("-ERR " + "Use jvm help"); return; } if (param[0].equals("dumpHeap")) { File file = getFile("dumpHeap", ".bin"); JvmUtil.dumpHeap(file.getAbsolutePath(), true); handler.sendClientMsg("+OK File " + file.getAbsolutePath()); } else if (param[0].equals("dumpJmapHisto")) { if (param.length < 2)/*dumpJmapHisto file*/ { handler.sendClientMsg("-ERR " + "insufficient param"); return; } if (param[1].equals("file")) { File file = getFile("dumpJmapHisto", ".txt"); handler.sendClientMsg("+OK info follows"); handler.sendClientMsg("Starting.. "); JvmUtil.dumpJmapHisto(file.getAbsolutePath()); handler.sendClientMsg("Done - File " + file.getAbsolutePath()); handler.sendClientMsg("."); } else if (param[1].equals("log")) { handler.sendClientMsg("+OK info follows"); handler.sendClientMsg("Starting.. "); JvmUtil.dumpJmapHistoToLog(); handler.sendClientMsg("Done - Dumped to jdk log file"); handler.sendClientMsg("."); } else { handler.sendClientMsg("-ERR " + "bad param"); return; } } else if (param[0].equals("threadDump")) { if (param.length < 2)/*threadDump file*/ { handler.sendClientMsg("-ERR " + "insufficient param"); return; } if (param[1].equals("file")) { File file = getFile("threadDump", ".txt"); handler.sendClientMsg("+OK info follows"); handler.sendClientMsg("Starting.. "); JvmUtil.threadDump(file.getAbsolutePath()); handler.sendClientMsg("Done - File " + file.getAbsolutePath()); handler.sendClientMsg("."); } else if (param[1].equals("log")) { handler.sendClientMsg("+OK info follows"); handler.sendClientMsg("Starting.. "); JvmUtil.threadDumpToLog(); handler.sendClientMsg("Done - Dumped to jdk log file"); handler.sendClientMsg("."); } else { handler.sendClientMsg("-ERR " + "bad param"); return; } } else if (param[0].equals("dumpJStack")) { if (param.length < 2)/*dumpJStack file*/ { handler.sendClientMsg("-ERR " + "insufficient param"); return; } if (param[1].equals("file")) { File file = getFile("dumpJStack", ".txt"); handler.sendClientMsg("+OK info follows"); handler.sendClientMsg("Starting.. "); JvmUtil.dumpJStack(file.getAbsolutePath()); handler.sendClientMsg("Done - File " + file.getAbsolutePath()); handler.sendClientMsg("."); } else if (param[1].equals("log")) { handler.sendClientMsg("+OK info follows"); handler.sendClientMsg("Starting.. "); JvmUtil.dumpJStackToLog(); handler.sendClientMsg("Done - Dumped to jdk log file"); handler.sendClientMsg("."); } else { handler.sendClientMsg("-ERR " + "bad param"); return; } } else if (param[0].equals("help")) { handler.sendClientMsg("+OK info follows"); handler.sendClientMsg("jvm dumpJmapHisto file"); handler.sendClientMsg("jvm dumpJStack file"); handler.sendClientMsg(" "); handler.sendClientMsg("jvm threadDump file"); handler.sendClientMsg("jvm dumpHeap"); handler.sendClientMsg(" "); handler.sendClientMsg("jvm threadDump log"); handler.sendClientMsg("jvm dumpJmapHisto log"); handler.sendClientMsg("jvm dumpJStack log"); handler.sendClientMsg("."); return; } else { handler.sendClientMsg("-ERR " + "bad param use jvm help"); } return; } if (param.length > 0) { if (param[0].equals("server")) target = (QuickServer) handler.getServer().getStoreObjects()[0]; else if (param[0].equals("self")) target = handler.getServer(); else { handler.sendClientMsg("-ERR Bad <<target>> : " + param[0]); return; } } if (cmd.equals("help")) { handler.sendClientMsg( "+OK info follows" + "\r\n" + "Refer Api Docs for org.quickserver.net.qsadmin.CommandHandler"); handler.sendClientMsg("."); return; } else if (cmd.equals("quit")) { handler.sendClientMsg("+OK Bye ;-)"); handler.closeConnection(); return; } else if (cmd.equals("shutdown")) { try { QuickServer controlServer = (QuickServer) handler.getServer().getStoreObjects()[0]; if (controlServer != null && controlServer.isClosed() == false) { controlServer.stopServer(); } if (handler.getServer() != null && handler.getServer().isClosed() == false) { handler.getServer().stopServer(); } QSAdminShell shell = QSAdminShell.getInstance(null, null); if (shell != null) { try { shell.stopShell(); } catch (Exception err) { logger.warning("Error stoping shell: " + err); } } handler.sendClientMsg("+OK Done"); } catch (AppException e) { handler.sendClientMsg("-ERR " + e); } return; } else if (cmd.equals("version")) { handler.sendClientMsg("+OK " + QuickServer.getVersion()); return; } else if (cmd.equals("kill") || cmd.equals("exit")) /*v1.3,v1.3.2*/ { StringBuilder errBuf = new StringBuilder(); QuickServer controlServer = (QuickServer) handler.getServer().getStoreObjects()[0]; int exitCode = 0; if (param.length != 0) { try { exitCode = Integer.parseInt(param[0]); } catch (Exception nfe) { /*ignore*/} } try { if (controlServer != null && controlServer.isClosed() == false) { try { controlServer.stopServer(); } catch (AppException ae) { errBuf.append(ae.toString()); } } if (handler.getServer() != null && handler.getServer().isClosed() == false) { try { handler.getServer().stopServer(); } catch (AppException ae) { errBuf.append(ae.toString()); } } QSAdminShell shell = QSAdminShell.getInstance(null, null); if (shell != null) { try { shell.stopShell(); } catch (Exception err) { errBuf.append(err.toString()); } } if (errBuf.length() == 0) handler.sendClientMsg("+OK Done"); else handler.sendClientMsg("+OK Done, Errors: " + errBuf.toString()); } catch (Exception e) { handler.sendClientMsg("-ERR Exception : " + e + "\r\n" + errBuf.toString()); if (exitCode == 0) exitCode = 1; } finally { try { if (controlServer != null) controlServer.closeAllPools(); if (handler.getServer() != null) handler.getServer().closeAllPools(); } catch (Exception er) { logger.warning("Error closing pools: " + er); } System.exit(exitCode); } return; } else if (cmd.equals("memoryinfo")) { /*v1.3.2*/ //Padding : Total:Used:Max float totalMemory = (float) runtime.totalMemory(); float usedMemory = totalMemory - (float) runtime.freeMemory(); float maxMemory = (float) runtime.maxMemory(); handler.sendClientMsg("+OK " + totalMemory + ":" + usedMemory + ":" + maxMemory); return; } else if (cmd.equals("systeminfo")) { /*v1.4.5*/ handler.sendClientMsg("+OK info follows"); handler.sendClientMsg(MyString.getSystemInfo(target.getVersion())); handler.sendClientMsg("."); return; } else if (param.length == 0) { handler.sendClientMsg("-ERR Bad Command or No Param : ->" + cmd + "<-"); return; } if (cmd.equals("start")) { try { target.startServer(); handler.sendClientMsg("+OK Server Started"); } catch (AppException e) { handler.sendClientMsg("-ERR " + e); } return; } else if (cmd.equals("stop")) { try { target.stopServer(); handler.sendClientMsg("+OK Server Stopped"); } catch (AppException e) { handler.sendClientMsg("-ERR " + e); } return; } else if (cmd.equals("restart")) { try { target.stopServer(); target.startServer(); handler.sendClientMsg("+OK Server Restarted"); } catch (AppException e) { handler.sendClientMsg("-ERR " + e); } return; } else if (cmd.equals("info")) { handler.sendClientMsg("+OK info follows"); handler.sendClientMsg("" + target); handler.sendClientMsg("Running : " + !target.isClosed()); handler.sendClientMsg("PID : " + QuickServer.getPID()); handler.sendClientMsg("Max Client Allowed : " + target.getMaxConnection()); handler.sendClientMsg("No Client Connected : " + target.getClientCount()); if (target.isRunningSecure() == true) { handler.sendClientMsg("Running in secure mode : " + target.getSecure().getProtocol()); } else { handler.sendClientMsg("Running in non-secure mode"); } handler.sendClientMsg("Server Mode : " + target.getBasicConfig().getServerMode()); handler.sendClientMsg("QuickServer v : " + QuickServer.getVersion()); handler.sendClientMsg("Uptime : " + target.getUptime()); handler.sendClientMsg("."); return; } else if (cmd.equals("noclient")) { handler.sendClientMsg("+OK " + target.getClientCount()); return; } else if (cmd.equals("running")) { handler.sendClientMsg("+OK " + !target.isClosed()); return; } else if (cmd.equals("suspendservice")) { handler.sendClientMsg("+OK " + target.suspendService()); return; } else if (cmd.equals("resumeservice")) { handler.sendClientMsg("+OK " + target.resumeService()); return; } else if (cmd.equals("client-thread-pool-info")) /*v1.3.2*/ { temp.setLength(0);//used:idle if (PoolHelper.isPoolOpen(target.getClientPool().getObjectPool()) == true) { temp.append(target.getClientPool().getNumActive()); temp.append(':'); temp.append(target.getClientPool().getNumIdle()); } else { temp.append("0:0"); } handler.sendClientMsg("+OK " + temp.toString()); return; } else if (cmd.equals("client-thread-pool-dump")) /*v1.4.5*/ { if (PoolHelper.isPoolOpen(target.getClientPool().getObjectPool()) == true) { handler.sendClientMsg("+OK info follows"); ClientThread ct = null; synchronized (target.getClientPool().getObjectToSynchronize()) { Iterator iterator = target.getClientPool().getAllClientThread(); while (iterator.hasNext()) { ct = (ClientThread) iterator.next(); handler.sendClientMsg(ct.toString()); } } handler.sendClientMsg("."); } else { handler.sendClientMsg("-ERR Pool Closed"); } return; } else if (cmd.equals("client-handler-pool-dump")) /*v1.4.6*/ { ObjectPool objectPool = target.getClientHandlerPool(); if (PoolHelper.isPoolOpen(objectPool) == true) { if (QSObjectPool.class.isInstance(objectPool) == false) { handler.sendClientMsg("-ERR System Error!"); } ClientIdentifier clientIdentifier = target.getClientIdentifier(); ClientHandler foundClientHandler = null; synchronized (clientIdentifier.getObjectToSynchronize()) { Iterator iterator = clientIdentifier.findAllClient(); handler.sendClientMsg("+OK info follows"); while (iterator.hasNext()) { foundClientHandler = (ClientHandler) iterator.next(); handler.sendClientMsg(foundClientHandler.info()); } } handler.sendClientMsg("."); } else { handler.sendClientMsg("-ERR Pool Closed"); } return; } else if (cmd.equals("client-data-pool-info")) /*v1.3.2*/ { temp.setLength(0);//used:idle if (target.getClientDataPool() != null) { if (PoolHelper.isPoolOpen(target.getClientDataPool()) == true) { temp.append(target.getClientDataPool().getNumActive()); temp.append(':'); temp.append(target.getClientDataPool().getNumIdle()); handler.sendClientMsg("+OK " + temp.toString()); } else { handler.sendClientMsg("-ERR Client Data Pool Closed"); } } else { handler.sendClientMsg("-ERR No Client Data Pool"); } return; } else if (cmd.equals("byte-buffer-pool-info")) /*v1.4.6*/ { temp.setLength(0);//used:idle if (target.getByteBufferPool() != null) { if (PoolHelper.isPoolOpen(target.getByteBufferPool()) == true) { temp.append(target.getByteBufferPool().getNumActive()); temp.append(':'); temp.append(target.getByteBufferPool().getNumIdle()); handler.sendClientMsg("+OK " + temp.toString()); } else { handler.sendClientMsg("-ERR ByteBuffer Pool Closed"); } } else { handler.sendClientMsg("-ERR No ByteBuffer Pool"); } return; } else if (cmd.equals("all-pool-info")) /*v1.4.5*/ { handler.sendClientMsg("+OK info follows"); temp.setLength(0);//used:idle if (PoolHelper.isPoolOpen(target.getClientPool().getObjectPool()) == true) { temp.append("Client Thread Pool - "); temp.append("Num Active: "); temp.append(target.getClientPool().getNumActive()); temp.append(", Num Idle: "); temp.append(target.getClientPool().getNumIdle()); temp.append(", Max Idle: "); temp.append(target.getClientPool().getPoolConfig().getMaxIdle()); temp.append(", Max Active: "); temp.append(target.getClientPool().getPoolConfig().getMaxActive()); } else { temp.append("Byte Buffer Pool - Closed"); } handler.sendClientMsg(temp.toString()); temp.setLength(0); if (PoolHelper.isPoolOpen(target.getClientHandlerPool()) == true) { temp.append("Client Handler Pool - "); temp.append("Num Active: "); temp.append(target.getClientHandlerPool().getNumActive()); temp.append(", Num Idle: "); temp.append(target.getClientHandlerPool().getNumIdle()); temp.append(", Max Idle: "); temp.append(target.getBasicConfig().getObjectPoolConfig().getClientHandlerObjectPoolConfig() .getMaxIdle()); temp.append(", Max Active: "); temp.append(target.getBasicConfig().getObjectPoolConfig().getClientHandlerObjectPoolConfig() .getMaxActive()); } else { temp.append("Client Handler Pool - Closed"); } handler.sendClientMsg(temp.toString()); temp.setLength(0); if (target.getByteBufferPool() != null) { if (PoolHelper.isPoolOpen(target.getByteBufferPool()) == true) { temp.append("ByteBuffer Pool - "); temp.append("Num Active: "); temp.append(target.getByteBufferPool().getNumActive()); temp.append(", Num Idle: "); temp.append(target.getByteBufferPool().getNumIdle()); temp.append(", Max Idle: "); temp.append(target.getBasicConfig().getObjectPoolConfig().getByteBufferObjectPoolConfig() .getMaxIdle()); temp.append(", Max Active: "); temp.append(target.getBasicConfig().getObjectPoolConfig().getByteBufferObjectPoolConfig() .getMaxActive()); } else { temp.append("Byte Buffer Pool - Closed"); } } else { temp.append("Byte Buffer Pool - Not Used"); } handler.sendClientMsg(temp.toString()); temp.setLength(0); if (target.getClientDataPool() != null) { if (PoolHelper.isPoolOpen(target.getClientDataPool()) == true) { temp.append("Client Data Pool - "); temp.append("Num Active: "); temp.append(target.getClientDataPool().getNumActive()); temp.append(", Num Idle: "); temp.append(target.getClientDataPool().getNumIdle()); temp.append(", Max Idle: "); temp.append(target.getBasicConfig().getObjectPoolConfig().getClientDataObjectPoolConfig() .getMaxIdle()); temp.append(", Max Active: "); temp.append(target.getBasicConfig().getObjectPoolConfig().getClientDataObjectPoolConfig() .getMaxActive()); } else { temp.append("Client Data Pool - Closed"); } } else { temp.append("Client Data Pool - Not Used"); } handler.sendClientMsg(temp.toString()); temp.setLength(0); handler.sendClientMsg("."); return; } else if (cmd.equals("set")) { if (param.length < 3)/*target,key,value*/ { handler.sendClientMsg("-ERR " + "insufficient param"); return; } if (param[2].equals("null")) param[2] = null; try { if (param[1].equals("maxClient")) { long no = Long.parseLong(param[2]); target.setMaxConnection(no); } else if (param[1].equals("maxClientMsg")) { target.setMaxConnectionMsg(param[2]); } else if (param[1].equals("port")) { long no = Long.parseLong(param[2]); target.setPort((int) no); } else if (param[1].equals("port")) { long no = Long.parseLong(param[2]); target.setPort((int) no); } else if (param[1].equals("maxAuthTry")) { int no = Integer.parseInt(param[2]); target.setMaxAuthTry(no); } else if (param[1].equals("maxAuthTryMsg")) { target.setMaxAuthTryMsg(param[2]); } else if (param[1].equals("clientEventHandler")) { /*v1.4.6*/ target.setClientEventHandler(param[2]); } else if (param[1].equals("clientCommandHandler")) { target.setClientCommandHandler(param[2]); } else if (param[1].equals("clientWriteHandler")) { /*v1.4.6*/ target.setClientWriteHandler(param[2]); } else if (param[1].equals("clientObjectHandler")) { target.setClientObjectHandler(param[2]); /*v1.3*/ } else if (param[1].equals("clientAuthenticationHandler")) { target.setClientAuthenticationHandler(param[2]); } else if (param[1].equals("clientData")) { target.setClientData(param[2]); } else if (param[1].equals("clientExtendedEventHandler")) { /*v1.4.6*/ target.setClientExtendedEventHandler(param[2]); } else if (param[1].equals("timeout")) { long no = Long.parseLong(param[2]); target.setTimeout((int) no); } else if (param[1].equals("timeoutMsg")) { target.setTimeoutMsg(param[2]); /* v1.3 */ } else if (param[1].equals("plugin")) /* v1.2*/ { if (param[0].equals("self")) { try { adminServer.setCommandPlugin(param[2]); } catch (Exception e) { handler.sendClientMsg("-ERR not set : " + e); return; } } else { handler.sendClientMsg("-ERR Bad target : " + param[0] + " self is only allowed."); return; } } else if (param[1].equals("consoleLoggingFormatter")) { target.setConsoleLoggingFormatter(param[2]); /* v1.3 */ } else if (param[1].equals("consoleLoggingLevel")) { /* v1.3 */ if (param[2].endsWith("SEVERE")) target.setConsoleLoggingLevel(Level.SEVERE); else if (param[2].endsWith("WARNING")) target.setConsoleLoggingLevel(Level.WARNING); else if (param[2].endsWith("INFO")) target.setConsoleLoggingLevel(Level.INFO); else if (param[2].endsWith("CONFIG")) target.setConsoleLoggingLevel(Level.CONFIG); else if (param[2].endsWith("FINE")) target.setConsoleLoggingLevel(Level.FINE); else if (param[2].endsWith("FINER")) target.setConsoleLoggingLevel(Level.FINER); else if (param[2].endsWith("FINEST")) target.setConsoleLoggingLevel(Level.FINEST); else if (param[2].endsWith("ALL")) target.setConsoleLoggingLevel(Level.ALL); else if (param[2].endsWith("OFF")) target.setConsoleLoggingLevel(Level.OFF); else { handler.sendClientMsg("-ERR Bad Level " + param[2]); return; } } else if (param[1].equals("loggingLevel")) { /* v1.3.1 */ if (param[2].endsWith("SEVERE")) target.setLoggingLevel(Level.SEVERE); else if (param[2].endsWith("WARNING")) target.setLoggingLevel(Level.WARNING); else if (param[2].endsWith("INFO")) target.setLoggingLevel(Level.INFO); else if (param[2].endsWith("CONFIG")) target.setLoggingLevel(Level.CONFIG); else if (param[2].endsWith("FINE")) target.setLoggingLevel(Level.FINE); else if (param[2].endsWith("FINER")) target.setLoggingLevel(Level.FINER); else if (param[2].endsWith("FINEST")) target.setLoggingLevel(Level.FINEST); else if (param[2].endsWith("ALL")) target.setLoggingLevel(Level.ALL); else if (param[2].endsWith("OFF")) target.setLoggingLevel(Level.OFF); else { handler.sendClientMsg("-ERR Bad Level " + param[2]); return; } } else if (param[1].equals("communicationLogging")) { if (param[2].equals("true"))/* v1.3.2 */ target.setCommunicationLogging(true); else target.setCommunicationLogging(false); } else if (param[1].equals("objectPoolConfig-maxActive")) { int no = Integer.parseInt(param[2]); target.getConfig().getObjectPoolConfig().setMaxActive(no); } else if (param[1].equals("objectPoolConfig-maxIdle")) { int no = Integer.parseInt(param[2]); target.getConfig().getObjectPoolConfig().setMaxIdle(no); } else if (param[1].equals("objectPoolConfig-initSize")) { int no = Integer.parseInt(param[2]); target.getConfig().getObjectPoolConfig().setInitSize(no); } else { handler.sendClientMsg("-ERR Bad Set Key : " + param[1]); return; } handler.sendClientMsg("+OK Set"); } catch (Exception e) { handler.sendClientMsg("-ERR " + e); } return; } else if (cmd.equals("get")) { if (param.length < 2)/*target,key*/ { handler.sendClientMsg("-ERR " + "insufficient param"); return; } try { if (param[1].equals("maxClient")) { long no = target.getMaxConnection(); handler.sendClientMsg("+OK " + no); } else if (param[1].equals("maxClientMsg")) { String msg = target.getMaxConnectionMsg(); msg = MyString.replaceAll(msg, "\n", "\\n"); handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("port")) { long no = target.getPort(); handler.sendClientMsg("+OK " + no); } else if (param[1].equals("maxAuthTry")) { int no = target.getMaxAuthTry(); handler.sendClientMsg("+OK " + no); } else if (param[1].equals("maxAuthTryMsg")) { String msg = target.getMaxAuthTryMsg(); msg = MyString.replaceAll(msg, "\n", "\\n"); handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("clientEventHandler")) { /*v1.4.6*/ String msg = target.getClientEventHandler(); handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("clientCommandHandler")) { String msg = target.getClientCommandHandler(); handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("clientWriteHandler")) { /*v1.4.6*/ String msg = target.getClientWriteHandler(); handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("clientObjectHandler")) { String msg = target.getClientObjectHandler(); handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("clientAuthenticationHandler")) { String msg = target.getClientAuthenticationHandler(); handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("clientData")) { String msg = target.getClientData(); handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("clientExtendedEventHandler")) { /*v1.4.6*/ String msg = target.getClientExtendedEventHandler(); handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("timeout")) { String msg = "" + target.getTimeout(); handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("timeoutMsg")) { String msg = "" + target.getTimeoutMsg(); msg = MyString.replaceAll(msg, "\n", "\\n"); handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("plugin")) /* v1.2*/ { if (param[0].equals("self")) { String msg = adminServer.getCommandPlugin(); handler.sendClientMsg("+OK " + msg); } else { handler.sendClientMsg("-ERR Bad target : " + param[0] + " self is only allowed."); } } else if (param[1].equals("consoleLoggingFormatter")) { String msg = "" + target.getConsoleLoggingFormatter(); /* v1.3 */ handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("consoleLoggingLevel")) { /* v1.3 */ String msg = "" + target.getConsoleLoggingLevel(); handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("serviceState")) { int state = target.getServiceState(); /*v1.3*/ if (state == org.quickserver.net.Service.INIT) handler.sendClientMsg("+OK INIT"); else if (state == org.quickserver.net.Service.RUNNING) handler.sendClientMsg("+OK RUNNING"); else if (state == org.quickserver.net.Service.STOPPED) handler.sendClientMsg("+OK STOPPED"); else if (state == org.quickserver.net.Service.SUSPENDED) handler.sendClientMsg("+OK SUSPENDED"); else handler.sendClientMsg("+OK UNKNOWN"); } else if (param[1].equals("communicationLogging")) { String msg = "" + target.getCommunicationLogging(); handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("objectPoolConfig-maxActive")) { String msg = "" + target.getConfig().getObjectPoolConfig().getMaxActive(); handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("objectPoolConfig-maxIdle")) { String msg = "" + target.getConfig().getObjectPoolConfig().getMaxIdle(); handler.sendClientMsg("+OK " + msg); } else if (param[1].equals("objectPoolConfig-initSize")) { String msg = "" + target.getConfig().getObjectPoolConfig().getInitSize(); handler.sendClientMsg("+OK " + msg); } else { handler.sendClientMsg("-ERR Bad Get Key : " + param[1]); } } catch (Exception e) { handler.sendClientMsg("-ERR " + e); } return; } else if (cmd.equals("kill-clients-all")) /*v2.0.0*/ { ObjectPool objectPool = target.getClientHandlerPool(); if (PoolHelper.isPoolOpen(objectPool) == true) { if (QSObjectPool.class.isInstance(objectPool) == false) { handler.sendClientMsg("-ERR System Error!"); } ClientIdentifier clientIdentifier = target.getClientIdentifier(); ClientHandler foundClientHandler = null; synchronized (clientIdentifier.getObjectToSynchronize()) { Iterator iterator = clientIdentifier.findAllClient(); handler.sendClientMsg("+OK closing"); int count = 0; int found = 0; while (iterator.hasNext()) { foundClientHandler = (ClientHandler) iterator.next(); found++; if (foundClientHandler.isClosed() == false) { foundClientHandler.closeConnection(); count++; } } handler.sendClientMsg("Count Found: " + found); handler.sendClientMsg("Count Closed: " + count); } handler.sendClientMsg("."); } else { handler.sendClientMsg("-ERR Closing"); } return; } else if (cmd.equals("kill-client-with")) /*v2.0.0*/ { if (param.length < 2)/*target,search*/ { handler.sendClientMsg("-ERR " + "insufficient param"); return; } String search = param[1]; ObjectPool objectPool = target.getClientHandlerPool(); if (PoolHelper.isPoolOpen(objectPool) == true) { if (QSObjectPool.class.isInstance(objectPool) == false) { handler.sendClientMsg("-ERR System Error!"); } ClientIdentifier clientIdentifier = target.getClientIdentifier(); ClientHandler foundClientHandler = null; synchronized (clientIdentifier.getObjectToSynchronize()) { Iterator iterator = clientIdentifier.findAllClient(); handler.sendClientMsg("+OK closing"); int count = 0; int found = 0; while (iterator.hasNext()) { foundClientHandler = (ClientHandler) iterator.next(); if (foundClientHandler.toString().indexOf(search) != -1) { found++; if (foundClientHandler.isClosed() == false) { foundClientHandler.closeConnection(); count++; } } } handler.sendClientMsg("Count Found: " + found); handler.sendClientMsg("Count Closed: " + count); } handler.sendClientMsg("."); } else { handler.sendClientMsg("-ERR Closing"); } return; } else { handler.sendClientMsg("-ERR Bad Command : " + cmd); } return; }
From source file:org.quickserver.net.server.QuickServer.java
/** * Sets the console log handler level.// ww w . j av a 2 s . c om * @since 1.2 */ public void setConsoleLoggingLevel(Level level) { Logger rlogger = Logger.getLogger(""); Handler[] handlers = rlogger.getHandlers(); boolean isConsole = true; try { if (System.console() == null) { isConsole = false; } } catch (Throwable e) { //ignore } for (int index = 0; index < handlers.length; index++) { if (ConsoleHandler.class.isInstance(handlers[index])) { if (isConsole == false && level != Level.OFF) { System.out.println("QuickServer: You do not have a console.. so turning console logger off.."); level = Level.OFF; } if (level == Level.OFF) { logger.info("QuickServer: Removing console handler.. "); rlogger.removeHandler(handlers[index]); handlers[index].setLevel(level); handlers[index].close(); } else { handlers[index].setLevel(level); } } } if (level == Level.SEVERE) consoleLoggingLevel = "SEVERE"; else if (level == Level.WARNING) consoleLoggingLevel = "WARNING"; else if (level == Level.INFO) consoleLoggingLevel = "INFO"; else if (level == Level.CONFIG) consoleLoggingLevel = "CONFIG"; else if (level == Level.FINE) consoleLoggingLevel = "FINE"; else if (level == Level.FINER) consoleLoggingLevel = "FINER"; else if (level == Level.FINEST) consoleLoggingLevel = "FINEST"; else if (level == Level.OFF) consoleLoggingLevel = "OFF"; else consoleLoggingLevel = "UNKNOWN"; logger.log(Level.FINE, "Set to {0}", level); }