private JSONObject getFilteredStatsForRollup(Rollup rollup, Set<MetricStat> filterStats) { final JSONObject filteredObject = new JSONObject(); for (MetricStat stat : filterStats) { try { Object filteredValue = stat.convertRollupToObject(rollup); if (filteredValue instanceof Map && stat == MetricStat.PERCENTILE) { for (Map.Entry entry : ((Map<?,?>)filteredValue).entrySet()) { BluefloodTimerRollup.Percentile pct = (BluefloodTimerRollup.Percentile)entry.getValue(); filteredObject.put(String.format("pct_%s", entry.getKey().toString()), pct.getMean()); } } else { filteredObject.put(stat.toString(), filteredValue); } } catch (UnsupportedOperationException ex) { log.debug(ex.toString()); } } return filteredObject; }
@ExceptionHandler({UnsupportedOperationException.class}) public ResponseEntity<Object> unsupportedOperation(HttpServletRequest req, UnsupportedOperationException exception) { logger.error("Unsupported operation: {}", exception.toString()); return errorResponse(req.getRequestURI(), new StatusCode(CodeEnum.CODE_403)); }
@PUT @Consumes(MediaType.APPLICATION_XML) public Response put(SyncConfig syncConfig) { try { int jobId = SyncJobService.getInstance().createJob(syncConfig); return Response.created(UriBuilder.fromPath("/" + jobId).build()).header("x-emc-job-id", jobId).build(); } catch (ConfigurationException e) { // config is bad return Response.status(Response.Status.BAD_REQUEST).type(MediaType.TEXT_PLAIN).entity(e.toString()).build(); } catch (UnsupportedOperationException e) { // can't create any more jobs return Response.status(Response.Status.CONFLICT).type(MediaType.TEXT_PLAIN).entity(e.toString()).build(); } }
@ExceptionHandler({UnsupportedOperationException.class}) public ResponseEntity<Object> unsupportedOperation(HttpServletRequest req, UnsupportedOperationException exception) { logger.error("Unsupported operation: {}", exception.toString()); return errorResponse(req.getRequestURI(), new StatusCode(CodeEnum.CODE_403)); }
@ExceptionHandler({UnsupportedOperationException.class}) public ResponseEntity<Object> unsupportedOperation(HttpServletRequest req, UnsupportedOperationException exception) { logger.error("Unsupported operation: {}", exception.toString()); return errorResponse(req.getRequestURI(), new StatusCode(CodeEnum.CODE_403)); }
@ExceptionHandler({UnsupportedOperationException.class}) public ResponseEntity<Object> unsupportedOperation(HttpServletRequest req, UnsupportedOperationException exception) { logger.error("Unsupported operation: {}", exception.toString()); return errorResponse(req.getRequestURI(), new StatusCode(CodeEnum.CODE_403)); }
@DELETE @Path("{jobId}") public Response delete(@PathParam("jobId") int jobId, @QueryParam("keepDatabase") boolean keepDatabase) { try { SyncJobService.getInstance().deleteJob(jobId, keepDatabase); return Response.ok().build(); } catch (JobNotFoundException e) { // job not found throw new NotFoundException(e.getMessage()); } catch (UnsupportedOperationException e) { // job is running or paused (can't be deleted) return Response.status(ClientResponse.Status.CONFLICT).type(MediaType.TEXT_PLAIN).entity(e.toString()).build(); } }
@Override protected void executeReadAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if ((PlatformMBeanUtil.JVM_MAJOR_VERSION > 6 && PlatformMBeanConstants.OBJECT_NAME.equals(name)) || PlatformMBeanConstants.COMPILATION_READ_ATTRIBUTES.contains(name) || PlatformMBeanConstants.COMPILATION_METRICS.contains(name)) { storeResult(name, context.getResult()); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (UnsupportedOperationException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } }
@Override protected void executeReadAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if ((PlatformMBeanUtil.JVM_MAJOR_VERSION > 6 && PlatformMBeanConstants.OBJECT_NAME.equals(name)) || PlatformMBeanConstants.THREADING_READ_ATTRIBUTES.contains(name) || PlatformMBeanConstants.THREADING_READ_WRITE_ATTRIBUTES.contains(name) || PlatformMBeanConstants.THREADING_METRICS.contains(name)) { storeResult(name, context.getResult()); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (SecurityException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } catch (UnsupportedOperationException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } }
@Override protected void executeReadAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if ((PlatformMBeanUtil.JVM_MAJOR_VERSION > 6 && PlatformMBeanConstants.OBJECT_NAME.equals(name)) || PlatformMBeanConstants.RUNTIME_READ_ATTRIBUTES.contains(name) || PlatformMBeanConstants.RUNTIME_METRICS.contains(name)) { storeResult(name, context.getResult()); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (SecurityException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } catch (UnsupportedOperationException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { validator.validate(operation); try { long id = operation.require(PlatformMBeanConstants.ID).asLong(); context.getResult().set(ManagementFactory.getThreadMXBean().getThreadUserTime(id)); } catch (UnsupportedOperationException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } context.stepCompleted(); }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { validator.validate(operation); try { long id = operation.require(PlatformMBeanConstants.ID).asLong(); context.getResult().set(ManagementFactory.getThreadMXBean().getThreadCpuTime(id)); } catch (UnsupportedOperationException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } context.stepCompleted(); }
@Override protected void executeReadAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if ((PlatformMBeanConstants.OBJECT_NAME.getName().equals(name)) || COMPILATION_READ_ATTRIBUTES.contains(name) || COMPILATION_METRICS.contains(name)) { storeResult(name, context.getResult()); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } }
@Override protected void executeReadAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if ((PlatformMBeanConstants.OBJECT_NAME.getName().equals(name)) || COMPILATION_READ_ATTRIBUTES.contains(name) || COMPILATION_METRICS.contains(name)) { storeResult(name, context.getResult()); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { validator.validate(operation); try { long id = operation.require(PlatformMBeanConstants.ID).asLong(); context.getResult().set(ManagementFactory.getThreadMXBean().getThreadUserTime(id)); } catch (UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { validator.validate(operation); try { long id = operation.require(PlatformMBeanConstants.ID).asLong(); context.getResult().set(ManagementFactory.getThreadMXBean().getThreadCpuTime(id)); } catch (UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { validator.validate(operation); try { long id = operation.require(PlatformMBeanConstants.ID).asLong(); context.getResult().set(ManagementFactory.getThreadMXBean().getThreadUserTime(id)); } catch (UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { validator.validate(operation); try { long id = operation.require(PlatformMBeanConstants.ID).asLong(); context.getResult().set(ManagementFactory.getThreadMXBean().getThreadCpuTime(id)); } catch (UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } } }
/** * Calls the JDBC code to be executed. */ protected void process() { if(JOrphanUtils.isBlank(getDataSource())) { throw new IllegalArgumentException("Variable Name must not be null in "+getName()); } try (Connection conn = DataSourceElement.getConnection(getDataSource())){ execute(conn); } catch (SQLException ex) { log.warn("SQL Problem in {}: {}", getName(), ex.toString()); } catch (IOException ex) { log.warn("IO Problem in {}: {}"+ getName(), ex.toString()); } catch (UnsupportedOperationException ex) { log.warn("Execution Problem in {}: {}", getName(), ex.toString()); } }
@Override protected void executeReadAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String memPoolName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if ((PlatformMBeanConstants.OBJECT_NAME.getName().equals(name)) || MemoryPoolResourceDefinition.MEMORY_POOL_READ_ATTRIBUTES.contains(name) || MemoryPoolResourceDefinition.MEMORY_POOL_READ_WRITE_ATTRIBUTES.contains(name) || MemoryPoolResourceDefinition.MEMORY_POOL_METRICS.contains(name)) { MemoryPoolMXBean memoryPoolMXBean = getMemoryPoolMXBean(memPoolName); storeResult(name, context.getResult(), memoryPoolMXBean, memPoolName); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } }