@RabbitListener(queues = {"customer.update"}) public void updateCustomer(String message) throws InterruptedException, IOException { Profile profile = objectMapper.readValue(message, Profile.class); try { // Update the customer service for the profile UpdateCustomerResponse response = customerClient.updateCustomerResponse(profile); if (!response.isSuccess()) { String errorMsg = String.format("Could not update customer from profile for %s", profile.getUsername()); log.error(errorMsg); throw new UnexpectedException(errorMsg); } } catch (Exception ex) { // Throw AMQP exception and redeliver the message throw new AmqpIllegalStateException("Customer service update failed", ex); } }
/** * Wraps an exception thrown by an implementation * method. It returns the corresponding client-side exception. * @param orig the exception to wrap. * @return the wrapped exception. */ public RemoteException wrapException(Throwable orig) { if (orig instanceof SystemException) { return mapSystemException((SystemException)orig); } if (orig instanceof Error) { return new ServerError("Error occurred in server thread",(Error)orig); } else if (orig instanceof RemoteException) { return new ServerException("RemoteException occurred in server thread", (Exception)orig); } else if (orig instanceof RuntimeException) { throw (RuntimeException) orig; } if (orig instanceof Exception) return new UnexpectedException( orig.toString(), (Exception)orig ); else return new UnexpectedException( orig.toString()); }
public Exception readException( ApplicationException ae ) { // Note that the exception ID is present in both ae // and in the input stream from ae. The exception // reader must actually read the exception ID from // the stream. InputStream is = (InputStream)ae.getInputStream() ; String excName = ae.getId() ; int index = findDeclaredException( excName ) ; if (index < 0) { excName = is.read_string() ; Exception res = new UnexpectedException( excName ) ; res.initCause( ae ) ; return res ; } return rws[index].read( is ) ; }
private static void showPlanchesterGUI() { try { primaryStage = new Stage(); primaryStage.setTitle("Planchester"); //primaryStage.setResizable(false); primaryStage.setMaximized(true); primaryStage.setOnCloseRequest(t -> { closePlanchester(); }); scene = new Scene(FXMLLoader.load(PlanchesterGUI.class.getResource("PlanchesterFrame.fxml"))); URL url = PlanchesterGUI.class.getResource("CSS/stylesheet.css"); if (url == null) { throw new UnexpectedException("CSS Resource not found. Aborting."); } String css = url.toExternalForm(); scene.getStylesheets().add(css); primaryStage.setScene(scene); primaryStage.getIcons().add(new Image("file:src/Presentation/Images/logoplanchester.png")); primaryStage.show(); } catch (IOException exception) { exception.printStackTrace(); } }
/** * The passed snapshot was successfully persisted; it can be let go. * @param ss The snapshot to clean out. * @throws UnexpectedException * @see #snapshot() */ void clearSnapshot(final SortedSet<KeyValue> ss) throws UnexpectedException { MemStoreLAB tmpAllocator = null; 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(); } this.snapshotSize = 0; if (this.snapshotAllocator != null) { tmpAllocator = this.snapshotAllocator; this.snapshotAllocator = null; } if (tmpAllocator != null) { tmpAllocator.close(); } }
/** * Populates model with the diagrams to be exported * * @throws ModelMapException * @throws ArrangeException * @throws UnknownDiagramTypeException * @throws UnexpectedEndException */ private void createModel() throws ModelMapException, ArrangeException, UnexpectedDiagramTypeException, UnexpectedEndException, UnexpectedException { for (Pair<String, DiagramExportationReport> report : layout.getReportsWithDiagramNames()) { String name = report.getFirst(); DiagramExportationReport der = report.getSecond(); // map connects the layout information to the EMF-UML model // informations ModelMapProvider map = new ModelMapProvider(URI.createFileURI(genFolder), der.getModelName()); model.createDiagram(name, report.getSecond(), map); } }
/** * The passed snapshot was successfully persisted; it can be let go. * @param ss The snapshot to clean out. * @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(); } }
private Object invokeRemoteMethod(Object proxy, Method m, Object[] args) throws Throwable { try { return ref.invoke((Remote) proxy, m, args, RMIHash.getMethodHash(m)); } catch (RuntimeException re) { throw re; } catch (Exception ex) { Method m1 = proxy.getClass().getMethod(m.getName(), m.getParameterTypes()); Class[] declaredEx = m1.getExceptionTypes(); for (int i = 0; i < declaredEx.length; ++i) { if (declaredEx[i].isAssignableFrom(ex.getClass())) { throw ex; } } // rmi.24=Unexpected exception throw new UnexpectedException(Messages.getString("rmi.24"), ex); //$NON-NLS-1$ } }
/** * parse comma separated value and store it * in proper types * @param id * @param vcfIdValue */ public VCFInfoElement(final String id, String vcfIdValue) throws UnexpectedException { this.type = getType(id); String[] valueArray = vcfIdValue.split(","); if (type == int[].class) { int[] nums = new int[valueArray.length]; for (int i = 0; i < valueArray.length; i++) { nums[i] = Integer.parseInt(valueArray[i]); } this.value = type.cast(nums); } else if (type == String[].class) { this.value = type.cast(valueArray); } else { throw new UnexpectedException("ERROR: only Integer and String supported for INFO field (" + id + ")."); } }
@Before public void setup() throws UnexpectedException{ parser = new VCFparser(); parser.processLine("##fileformat=VCFv4.1"); parser.processLine("##reference=src/test/resources/DuplicationTest/oneDuplicationTest.fa"); parser.processLine("##INFO=<ID=SVLEN,Number=.,Type=Integer,Description=\"Length of variant\">"); parser.processLine("##INFO=<ID=SVTYPE,Number=1,Type=String,Description=\"Type of structural variant\">"); parser.processLine("##FORMAT=<ID=GT,Number=1,Type=String,Description=\"Genotype\">"); parser.processLine("##ALT=<ID=DEL,Description=\"Deletion\">"); parser.processLine("##ALT=<ID=DEL:ME:ALU,Description=\"Deletion of ALU element\">"); parser.processLine("##ALT=<ID=DEL:ME:L1,Description=\"Deletion of L1 element\">"); parser.processLine("##ALT=<ID=DUP,Description=\"Duplication\">"); parser.processLine("##ALT=<ID=DUP:TANDEM,Description=\"Tandem Duplication\">"); parser.processLine("##ALT=<ID=INS,Description=\"Insertion of novel sequence\">"); parser.processLine("##ALT=<ID=INS:ME:ALU,Description=\"Insertion of ALU element\">"); parser.processLine("##ALT=<ID=INS:ME:L1,Description=\"Insertion of L1 element\">"); parser.processLine("##ALT=<ID=INV,Description=\"Inversion\">"); parser.processLine("##ALT=<ID=CNV,Description=\"Copy number variable region\">"); parser.processLine("##ALT=<ID=ITX,Description=\"Intra-chromosomal translocation\">"); parser.processLine("##ALT=<ID=CTX,Description=\"Inter-chromosomal translocation\">"); parser.processLine("#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT test"); }
/** * The passed snapshot was successfully persisted; it can be let go. * @param ss The snapshot to clean out. * @throws UnexpectedException * @see #snapshot() */ void clearSnapshot(final SortedSet<KeyValue> ss) throws UnexpectedException { MemStoreLAB tmpAllocator = null; 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(); } if (this.snapshotAllocator != null) { tmpAllocator = this.snapshotAllocator; this.snapshotAllocator = null; } if (tmpAllocator != null) { tmpAllocator.close(); } }
private long getNumber(byte[] arg0) throws Exception { byte[] by = hex.decode(arg0); ByteBuffer bb = ByteBuffer.allocate(by.length); bb.put(by); 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"); }
/** * The passed snapshot was successfully persisted; it can be let go. * @param ss The snapshot to clean out. * @throws UnexpectedException * @see {@link #snapshot()} */ void clearSnapshot(final SortedSet<KeyValue> ss) throws UnexpectedException { 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(); } }
private long runSnapshot(final MemStore hmc) throws UnexpectedException { // Save off old state. int oldHistorySize = hmc.getSnapshot().size(); hmc.snapshot(); KeyValueSkipListSet ss = hmc.getSnapshot(); // Make some assertions about what just happened. assertTrue("History size has not increased", oldHistorySize < ss.size()); long t = memstore.timeOfOldestEdit(); assertTrue("Time of oldest edit is not Long.MAX_VALUE", t == Long.MAX_VALUE); hmc.clearSnapshot(ss); return t; }