List of usage examples for java.rmi UnexpectedException UnexpectedException
public UnexpectedException(String s)
UnexpectedException
with the specified detail message. From source file:com.netflix.aegisthus.pig.AegisthusLoadCaster.java
private long getNumber(byte[] arg0) throws Exception { byte[] by = hex.decode(arg0); ByteBuffer bb = ByteBuffer.allocate(by.length); bb.put(by);/* w ww . ja va 2 s.co m*/ bb.position(0); switch (by.length) { case 1: return (long) bb.get(); case 2: return (long) bb.getShort(); case 4: return (long) bb.getInt(); case 8: return (long) bb.getLong(); } throw new UnexpectedException("couldn't determine datatype"); }
From source file:com.newrelic.agent.transport.DataSenderImpl.java
private Map<String, Object> doConnect(Map<String, Object> startupOptions) /* 268: */ throws Exception /* 269: */ {//from w w w . j a v a2 s. c o m /* 270:260 */ InitialSizedJsonArray params = new InitialSizedJsonArray(1); /* 271:261 */ params.add(startupOptions); /* 272:262 */ Object response = invokeNoRunId("connect", "deflate", params); /* 273:263 */ if (!(response instanceof Map)) /* 274: */ { /* 275:264 */ String msg = MessageFormat.format("Expected a map of connection data, got {0}", new Object[] { response }); /* 276:265 */ throw new UnexpectedException(msg); /* 277: */ } /* 278:267 */ Map<String, Object> data = (Map) response; /* 279:268 */ if (data.containsKey("agent_run_id")) /* 280: */ { /* 281:269 */ Object runId = data.get("agent_run_id"); /* 282:270 */ setAgentRunId(runId); /* 283: */ } /* 284: */ else /* 285: */ { /* 286:272 */ String msg = MessageFormat.format("Missing {0} connection parameter", new Object[] { "agent_run_id" }); /* 287:273 */ throw new UnexpectedException(msg); /* 288: */ } /* 289:275 */ Object ssl = data.get("ssl"); /* 290:276 */ if (Boolean.TRUE.equals(ssl)) /* 291: */ { /* 292:277 */ Agent.LOG.info("Setting protocol to \"https\""); /* 293:278 */ this.protocol = "https"; /* 294: */ } /* 295:280 */ return data; /* 296: */ }
From source file:org.apache.hadoop.hbase.regionserver.Memcache.java
/** * The passed snapshot was successfully persisted; it can be let go. * @param ss The snapshot to clean out./*from w w w. j a va 2 s .c o m*/ * @throws UnexpectedException * @see {@link #snapshot()} */ void clearSnapshot(final Set<KeyValue> ss) throws UnexpectedException { this.lock.writeLock().lock(); try { if (this.snapshot != ss) { throw new UnexpectedException("Current snapshot is " + this.snapshot + ", was passed " + ss); } // OK. Passed in snapshot is same as current snapshot. If not-empty, // create a new snapshot and let the old one go. if (!ss.isEmpty()) { this.snapshot = createSet(this.comparator); } } finally { this.lock.writeLock().unlock(); } }
From source file:org.apache.hadoop.hbase.regionserver.MemStore.java
/** * The passed snapshot was successfully persisted; it can be let go. * @param ss The snapshot to clean out.// w ww.j av a 2 s . c o m * @throws UnexpectedException * @see {@link #snapshot()} */ void clearSnapshot(final SortedSet<KeyValue> ss) throws UnexpectedException { this.lock.writeLock().lock(); try { if (this.snapshot != ss) { throw new UnexpectedException("Current snapshot is " + this.snapshot + ", was passed " + ss); } // OK. Passed in snapshot is same as current snapshot. If not-empty, // create a new snapshot and let the old one go. if (!ss.isEmpty()) { this.snapshot = new KeyValueSkipListSet(this.comparator); this.snapshotTimeRangeTracker = new TimeRangeTracker(); } } finally { this.lock.writeLock().unlock(); } }
From source file:org.archive.io.hbase.HBaseWriter.java
/** * Creates the crawl table in HBase./*from w w w.j a v a 2 s. c om*/ * * @param hbaseConfiguration * the c * @param hbaseTableName * the table * * @throws IOException * Signals that an I/O exception has occurred. */ private Table initializeCrawlTable(final Connection connection, final TableName outputTableName) throws IOException { // an HBase admin object to manage hbase tables. Admin hbaseAdmin = null; try { // create hbase admin instance to manage table attributes hbaseAdmin = connection.getAdmin(); if (hbaseAdmin.tableExists(outputTableName)) { boolean foundContentColumnFamily = false; boolean foundCURIColumnFamily = false; log.info("Checking table: " + outputTableName.getNameAsString() + " for structure..."); // Check the existing table and manipulate it if necessary // to conform to the pre-existing table schema. HTableDescriptor existingHBaseTable = hbaseAdmin.getTableDescriptor(outputTableName); for (HColumnDescriptor hColumnDescriptor : existingHBaseTable.getFamilies()) { if (hColumnDescriptor.getNameAsString() .equalsIgnoreCase(getHbaseParameters().getContentColumnFamily())) { foundContentColumnFamily = true; } else if (hColumnDescriptor.getNameAsString() .equalsIgnoreCase(getHbaseParameters().getCuriColumnFamily())) { foundCURIColumnFamily = true; } } // modify the table if it's missing any of the column families. if (!foundContentColumnFamily || !foundCURIColumnFamily) { log.info("Disabling table: " + outputTableName.getNameAsString()); hbaseAdmin.disableTable(outputTableName); if (!foundContentColumnFamily) { log.info("Adding column to table: " + outputTableName.getNameAsString() + " column: " + getHbaseParameters().getContentColumnFamily()); existingHBaseTable .addFamily(new HColumnDescriptor(getHbaseParameters().getContentColumnFamily())); } if (!foundCURIColumnFamily) { log.info("Adding column to table: " + outputTableName.getNameAsString() + " column: " + getHbaseParameters().getCuriColumnFamily()); existingHBaseTable .addFamily(new HColumnDescriptor(getHbaseParameters().getCuriColumnFamily())); } hbaseAdmin.modifyTable(outputTableName, existingHBaseTable); log.info("Enabling table: " + outputTableName.getNameAsString()); hbaseAdmin.enableTable(outputTableName); } log.info("Done checking table: " + outputTableName.getNameAsString()); } else { // create a new hbase table log.info("Creating table: " + outputTableName.getNameAsString()); HTableDescriptor newHBaseTable = new HTableDescriptor(TableName .valueOf(HBaseParameters.defaultHbaseTableNameSpace, outputTableName.getNameAsString())); newHBaseTable.addFamily(new HColumnDescriptor(getHbaseParameters().getContentColumnFamily())); newHBaseTable.addFamily(new HColumnDescriptor(getHbaseParameters().getCuriColumnFamily())); // create the table hbaseAdmin.createTable(newHBaseTable); log.info("Created table: " + newHBaseTable.getNameAsString()); } if (!hbaseAdmin.tableExists(outputTableName)) { throw new UnexpectedException("table does not exist: " + outputTableName.getNameAsString()); } if (!hbaseAdmin.isTableAvailable(outputTableName)) { throw new UnexpectedException("table is not available: " + outputTableName.getNameAsString()); } if (hbaseAdmin.isTableDisabled(outputTableName)) { throw new UnexpectedException("table is disabled: " + outputTableName.getNameAsString()); } // create the hbase table reference and return it return connection.getTable(outputTableName); } finally { if (hbaseAdmin != null) { hbaseAdmin.close(); } } }
From source file:org.esa.s2tbx.dataio.s2.S2TileOpImage.java
protected void decompressTile(final File outputFile, int jp2TileX, int jp2TileY) throws IOException { final int tileIndex = tileLayout.numXTiles * jp2TileY + jp2TileX; ProcessBuilder builder;//from ww w .j a v a 2s.c om if (S2Config.OPJ_DECOMPRESSOR_EXE != null) { if (org.apache.commons.lang.SystemUtils.IS_OS_WINDOWS) { String inputFileName = Utils.GetIterativeShortPathName(imageFile.getPath()); String outputFileName = outputFile.getPath(); if (inputFileName.length() == 0) { inputFileName = imageFile.getPath(); } Guardian.assertTrue("Image file exists", new File(inputFileName).exists()); builder = new ProcessBuilder(S2Config.OPJ_DECOMPRESSOR_EXE, "-i", inputFileName, "-o", outputFileName, "-r", getLevel() + "", "-t", tileIndex + ""); } else { SystemUtils.LOG.fine("Writing to " + outputFile.getPath()); Guardian.assertTrue("Image file exists", imageFile.exists()); builder = new ProcessBuilder(S2Config.OPJ_DECOMPRESSOR_EXE, "-i", imageFile.getPath(), "-o", outputFile.getPath(), "-r", getLevel() + "", "-t", tileIndex + ""); } } else { throw new UnexpectedException("OpenJpeg decompressor is not set"); } builder = builder.directory(cacheDir); try { builder.redirectErrorStream(true); CommandOutput result = OpenJpegUtils.runProcess(builder); final int exitCode = result.getErrorCode(); if (exitCode != 0) { SystemUtils.LOG.severe(String.format( "Failed to uncompress tile: %s, exitCode = %d, command = [%s], command stdoutput = [%s], command stderr = [%s]", imageFile.getPath(), exitCode, builder.command().toString(), result.getTextOutput(), result.getErrorOutput())); } } catch (InterruptedException e) { SystemUtils.LOG.severe("Process was interrupted, InterruptedException: " + e.getMessage()); } }
From source file:zoranodensha.api.vehicles.UVID.java
/** * Create a new UVID for the given vehicle and parameters. * //ww w . jav a 2s .co m * @throws UnexpectedException If the generated UVID is not accepted by itself. */ public UVID(IEntityTrackBound vehicle, String username) throws UnexpectedException { if (vehicle == null || username == null || username.length() <= 0) { throw new IllegalArgumentException( "[UVID] Tried creating UVID with invalid paramters: " + vehicle + " ; " + username); } String engine = ""; Iterator<IVehiclePart> itera = vehicle.getPartsList().iterator(); IVehiclePart part; boolean diesel = false, electric = false, magnetic = false, steam = false; while (itera.hasNext()) { part = itera.next(); if (part instanceof IVehiclePartEngine) { if (!diesel && part instanceof IVehiclePartEngine_Diesel) { diesel = true; engine += ENGINE_TYPES[0]; } if (!electric && part instanceof IVehiclePartEngine_Electric) { electric = true; engine += ENGINE_TYPES[1]; } if (!magnetic && part instanceof IVehiclePartEngine_Magnet) { magnetic = true; engine += ENGINE_TYPES[3]; } if (!steam && part instanceof IVehiclePartEngine_Steam) { steam = true; engine += ENGINE_TYPES[5]; } } } if (engine.length() == 0) { engine = String.valueOf(ENGINE_TYPES[4]); } else if (engine.length() > 1) { engine = String.valueOf(ENGINE_TYPES[2]); } String tmp = String.valueOf(MathHelper.clamp_int(vehicle.getMaxSpeed(), 0, 999)); String speed = ("000" + tmp).substring(tmp.length()); if (username.length() == 1) { username += username + username; } else if (username.length() == 2) { username += username.substring(1); } username = username.substring(0, 3); tmp = String.valueOf(ran.nextInt(100000)); String number = ("00000" + tmp).substring(tmp.length()); String uvid = (new SimpleDateFormat("yyyy-MM-dd")).format(new Date()).substring(1) + " " + engine + "-" + speed + " " + username.toUpperCase() + "-" + number; if (isValidUVID(uvid)) { this.string = uvid; } else { throw new UnexpectedException("[UVID] Generated UVID couldn't accept itself. [UVID: " + uvid + "]"); } }