List of usage examples for java.lang InternalError InternalError
public InternalError(Throwable cause)
From source file:net.sf.firemox.tools.MToolKit.java
/** * write a string to output stream ending with \0. * /*from w w w . j a va 2 s . c om*/ * @param out * is the input stream * @param string * the string to write */ public static void writeString(OutputStream out, String string) { try { if (string != null) { out.write(string.getBytes(CHARSET)); } out.write(0); } catch (Exception e) { throw new InternalError("writing string in file," + e); } }
From source file:com.swordlord.jalapeno.datatable.DataTableBase.java
public String getTableId() { String strClassName = this.getClass().getName(); String[] strElements = strClassName.split("\\."); if (strElements.length == 0) { throw new InternalError("strClassName is not OK"); }//from w w w. j a va 2s . co m String strName = strElements[strElements.length - 1]; strName = strName.replaceAll("DataTable", ""); return strName.toLowerCase(); }
From source file:FullThreadDump.java
/** * Constructs a ThreadMonitor object to get thread information in a remote * JVM.// w ww . ja v a 2 s.c om */ public ThreadMonitor(MBeanServerConnection server) throws IOException { this.server = server; this.tmbean = newPlatformMXBeanProxy(server, THREAD_MXBEAN_NAME, ThreadMXBean.class); try { objname = new ObjectName(THREAD_MXBEAN_NAME); } catch (MalformedObjectNameException e) { // should not reach here InternalError ie = new InternalError(e.getMessage()); ie.initCause(e); throw ie; } parseMBeanInfo(); }
From source file:net.sf.firemox.database.DatabaseFactory.java
/** * Retrieve data from the cache. If this card is not stored in cache, null * value is returned./*from w ww.j a v a 2 s . c o m*/ * * @param cardName * the card name (no translated one) * @param constraints * constraints set{key,value}. May be null. * @return the DatabaseCard object from the given card name from the cache. */ private static DatabaseCard getDatabaseFromCache(CardModel cardModel, Map<String, String> constraints) throws IOException, SAXException { if (config == null) { final XmlParser parser = new XmlParser(); Configuration.loadTemplateTbsFile(IdConst.FILE_DATABASE_SAVED); config = parser.parse(MToolKit.getTbsUrl(IdConst.FILE_DATABASE_SAVED).getPath()); } final List<Node> cachedInstances = config.getNodes(cardModel.getKeyName()); if (cachedInstances != null && !cachedInstances.isEmpty()) { final List<Node> validateCards = new ArrayList<Node>(); // This card is already cached once, keep only the best one int bestScore = 0; for (Node cachedCard : cachedInstances) { // Iterate over instances of this card assuming constraints. int score = 0; if (constraints != null && !constraints.isEmpty()) { for (Map.Entry<String, String> constraintKey : constraints.entrySet()) { final String constraintValue = constraintKey.getValue(); if (constraintValue == null || constraintValue.length() == 0) { // Invalid constraint ?! throw new InternalError( "No value associated to property '" + constraintKey.getKey() + "'"); } // Check the constraint against cached data of this card final List<Node> properties = cachedCard.getNodes("property"); if (properties != null && !properties.isEmpty()) { for (Node property : properties) { if (property.getAttribute("name").equalsIgnoreCase(constraintKey.getKey()) && property.getAttribute("value").equalsIgnoreCase(constraintValue)) { // the requested property has been found and does not match score++; break; } } } } } else { validateCards.add(cachedCard); break; } if (score > bestScore) { bestScore = score; validateCards.clear(); validateCards.add(cachedCard); } else if (score == bestScore) { validateCards.add(cachedCard); } } if (!validateCards.isEmpty()) { // All constraints are valid for these nodes Node preferredData = null; if (dataProxies == null) { return getDatabaseObjectCard(cardModel, cachedInstances.get(0), true); } for (Proxy dataProxy : dataProxies) { for (Node node : validateCards) { if (dataProxy.getName().equals(node.getAttribute("proxy"))) { preferredData = node; break; } } } if (preferredData == null) { // Do not retry a GET on a preferred proxy even if non ONE matches preferredData = validateCards.get(0); } if (constraints == null) { return getDatabaseObjectCard(cardModel, preferredData, true); } return getDatabaseObjectCard(cardModel, preferredData, bestScore >= constraints.size()); } /* * The card has been found in the cache but many constraints made failed * the extraction. We try the proxy 'update' and if failed too, then * return the first instance of cached data. */ // TODO try proxies first // return getDatabaseObjectCard(cardModel, cachedInstances.get(0)); } // This card is not yet cached, no database object created return null; }
From source file:com.chinamobile.bcbsp.util.JobStatus.java
@Override public Object clone() { try {// www . ja v a 2 s . c o m return super.clone(); } catch (CloneNotSupportedException cnse) { LOG.error("[clone]", cnse); throw new InternalError(cnse.toString()); } }
From source file:org.apache.tajo.master.TaskSchedulerImpl.java
@Override public void handle(TaskSchedulerEvent event) { int qSize = eventQueue.size(); if (qSize != 0 && qSize % 1000 == 0) { LOG.info("Size of event-queue in RMContainerAllocator is " + qSize); }// ww w . j av a2 s .co m int remCapacity = eventQueue.remainingCapacity(); if (remCapacity < 1000) { LOG.warn("Very low remaining capacity in the event-queue " + "of RMContainerAllocator: " + remCapacity); } try { eventQueue.put(event); } catch (InterruptedException e) { throw new InternalError(e.getMessage()); } }
From source file:com.manydesigns.portofino.actions.admin.ConnectionProvidersAction.java
private void buildConnectionProviderForm(Mode mode) { String[] fields;/*from ww w .jav a 2 s . c o m*/ if (connectionProvider instanceof JdbcConnectionProvider) { fields = (mode == Mode.VIEW) ? jdbcViewFields : jdbcEditFields; } else if (connectionProvider instanceof JndiConnectionProvider) { fields = (mode == Mode.VIEW) ? jndiViewFields : jndiEditFields; } else { throw new InternalError("Unknown connection provider type: " + connectionProvider.getClass().getName()); } form = new FormBuilder(ConnectionProviderForm.class).configFields(fields).configMode(mode).build(); }
From source file:net.sf.firemox.tools.MToolKit.java
/** * read a string from input The strings read end with \0 with no limit of size * /*from w ww .j a v a 2s .c o m*/ * @param inputStream * is the input stream containing content * @return the read string from the specified input stream */ public static String readText(InputStream inputStream) { StringBuffer string = new StringBuffer(100); try { int intRead; while ((intRead = inputStream.read()) != 0) { string.append((char) intRead); } } catch (Exception e) { throw new InternalError("reading text in file," + e); } return string.toString(); }
From source file:org.apache.jackrabbit.core.persistence.xml.XMLPersistenceManager.java
private String buildPropFilePath(PropertyId id) { String fileName;/*from w ww .java 2 s. com*/ try { MessageDigest md5 = MessageDigest.getInstance("MD5"); md5.update(id.getName().getNamespaceURI().getBytes()); md5.update(id.getName().getLocalName().getBytes()); byte[] bytes = md5.digest(); char[] chars = new char[32]; for (int i = 0, j = 0; i < 16; i++) { chars[j++] = HEXDIGITS[(bytes[i] >> 4) & 0x0f]; chars[j++] = HEXDIGITS[bytes[i] & 0x0f]; } fileName = new String(chars) + ".xml"; } catch (NoSuchAlgorithmException nsae) { // should never get here as MD5 should always be available in the JRE String msg = "MD5 not available"; log.error(msg, nsae); throw new InternalError(msg + nsae); } return buildNodeFolderPath(id.getParentId()) + "/" + fileName; }
From source file:org.apache.tajo.master.exec.DDLExecutor.java
public void dropIndex(final QueryContext queryContext, final DropIndexNode dropIndexNode) throws UndefinedIndexException, UndefinedDatabaseException { String databaseName, simpleIndexName; if (IdentifierUtil.isFQTableName(dropIndexNode.getIndexName())) { String[] splits = IdentifierUtil.splitFQTableName(dropIndexNode.getIndexName()); databaseName = splits[0];// w ww. j ava 2s.c o m simpleIndexName = splits[1]; } else { databaseName = queryContext.getCurrentDatabase(); simpleIndexName = dropIndexNode.getIndexName(); } if (!catalog.existIndexByName(databaseName, simpleIndexName)) { throw new UndefinedIndexException(simpleIndexName); } IndexDesc desc = catalog.getIndexByName(databaseName, simpleIndexName); catalog.dropIndex(databaseName, simpleIndexName); Path indexPath = new Path(desc.getIndexPath()); try { FileSystem fs = indexPath.getFileSystem(context.getConf()); fs.delete(indexPath, true); } catch (IOException e) { throw new InternalError(e.getMessage()); } LOG.info("Index " + simpleIndexName + " is dropped."); }