List of usage examples for javax.management MBeanException MBeanException
public MBeanException(java.lang.Exception e, String message)
MBeanException
that wraps the actual java.lang.Exception
with a detail message. From source file:org.skfiy.typhon.spi.GMConsoleProvider.java
/** * * @param uid/*from w w w .j av a2s.c o m*/ * @param iid * @param count * @throws javax.management.MBeanException */ public void pushItem(final String uid, final String iid, final String count) throws MBeanException { try { invoke(transcoding(uid), new Handler() { @Override void execute() { // Player player = SessionUtils.getPlayer(); ItemDobj itemDobj = itemProvider.getItem(iid); if (itemDobj instanceof HeroItemDobj) { throw new TyphonException("?"); } BagUtils.intoItem(itemDobj, Integer.valueOf(count)); } }); } catch (Exception e) { throw new MBeanException(e, e.getMessage()); } }
From source file:org.wso2.andes.server.information.management.SubscriptionManagementInformationMBean.java
/** * {@inheritDoc}//from w ww. j ava 2 s . c o m */ public int getTotalSubscriptionCountForSearchResult(boolean isDurable, boolean isActive, String protocolType, String destinationType, String filteredNamePattern, boolean isFilteredNameByExactMatch, String identifierPattern, boolean isIdentifierPatternByExactMatch, String ownNodeId) throws MBeanException { try { AndesSubscriptionManager subscriptionManager = AndesContext.getInstance().getAndesSubscriptionManager(); //get the searched subscriptions Set<AndesSubscription> searchSubscriptionList = subscriptionManager.getFilteredSubscriptions(isDurable, isActive, ProtocolType.valueOf(protocolType), DestinationType.valueOf(destinationType), filteredNamePattern, isFilteredNameByExactMatch, identifierPattern, isIdentifierPatternByExactMatch, ownNodeId); //count of search subscriptions return searchSubscriptionList.size(); } catch (Exception e) { log.error("Error while invoking MBeans to retrieve subscription information", e); throw new MBeanException(e, "Error while invoking MBeans to retrieve subscription information"); } }
From source file:org.wso2.andes.server.AMQBrokerManagerMBean.java
/** * Creates a new queue and registers it with the registry and puts it * in persistance storage if durable queue. * * @param queueName/*from w w w . j a v a 2 s. c o m*/ * @param durable * @param owner * @throws JMException * @throws MBeanException */ public void createNewQueue(String queueName, String owner, boolean durable, boolean exclusiveConsumer) throws JMException, MBeanException { AMQQueue queue = _queueRegistry.getQueue(new AMQShortString(queueName)); try { if (queue != null) { //ClusterResourceHolder.getInstance().getCassandraMessageStore().addQueue(queueName); throw new JMException("The queue \"" + queueName + "\" already exists."); } CurrentActor.set(new ManagementActor(_logActor.getRootMessageLogger())); AMQShortString ownerShortString = null; if (owner != null) { ownerShortString = new AMQShortString(owner); } queue = AMQQueueFactory.createAMQQueueImpl(new AMQShortString(queueName), durable, ownerShortString, false, false, getVirtualHost(), null); if (queue.isDurable() && !queue.isAutoDelete()) { _durableConfig.createQueue(queue); //tell Andes kernel to create queue QpidAMQPBridge.getInstance().createQueue(queue, exclusiveConsumer); } } catch (Exception ex) { JMException jme = new JMException(ex.toString()); throw new MBeanException(jme, "The queue \"" + queueName + "\" already exists."); } finally { CurrentActor.remove(); } }
From source file:org.skfiy.typhon.spi.GMConsoleProvider.java
/** * * @param uid/*from w w w. j av a2 s. c om*/ * @throws javax.management.MBeanException */ public void openAllPve(final String uid) throws MBeanException { try { invoke(transcoding(uid), new Handler() { @Override void execute() { Player player = SessionUtils.getPlayer(); Normal normal = player.getNormal(); // ? Field field = ReflectionUtils.findField(PveProvider.class, "historyChapters"); normal.setHpveProgresses(newPveProgressList(field)); // ?() field = ReflectionUtils.findField(PveProvider.class, "historyDifficultChapters"); normal.setHdpveProgresses(newPveProgressList(field)); } List<PveProgress> newPveProgressList(Field field) { field.setAccessible(true); List<Chapter> chapters = (List<Chapter>) ReflectionUtils.getField(field, pveProvider); List<PveProgress> list = new ArrayList<>(); for (int i = 0; i < chapters.size(); i++) { Chapter c = chapters.get(i); for (int j = 0; j < c.getParts().length; j++) { PveProgress pp = new PveProgress(i, j); list.add(pp); } } return list; } }); } catch (Exception e) { throw new MBeanException(e, e.getMessage()); } }
From source file:org.wso2.andes.server.AMQBrokerManagerMBean.java
/** * Deletes the queue from queue registry and persistant storage. * * @param queueName/*from ww w .java 2 s. com*/ * @throws JMException * @throws MBeanException */ public void deleteQueue(final String queueName) throws JMException, MBeanException { AMQQueue queue = _queueRegistry.getQueue(new AMQShortString(queueName)); if (queue == null) { throw new JMException("The Queue " + queueName + " is not a registered queue."); } try { boolean isQueueDeletable = ClusterResourceHolder.getInstance().getVirtualHostConfigSynchronizer() .checkIfQueueDeletable(queue); if (isQueueDeletable) { CurrentActor.set(new ManagementActor(_logActor.getRootMessageLogger())); queue.delete(); if (queue.isDurable()) { _durableConfig.removeQueue(queue); } //tell Andes kernel to remove queue QpidAMQPBridge.getInstance().deleteQueue(queue); } else { _logActor.message(new LogMessage() { String message = "Cannot Delete Queue" + queueName + " It Has Registered Subscriptions."; public String toString() { return message; } public String getLogHierarchy() { return "amqp.queue"; } }); throw new AMQException("Cannot Delete Queue" + queueName + " It Has Registered Subscriptions."); } } catch (AMQException ex) { JMException jme = new JMException(ex.toString()); if (ex.toString().contains("not a registered queue")) { throw new MBeanException(jme, "The Queue " + queueName + " is not a registered queue."); } else if (ex.toString().contains("Has Registered Subscriptions")) { throw new MBeanException(jme, "Queue " + queueName + " has active subscribers. Please stop them first."); } else { throw new MBeanException(jme, "Error in deleting queue " + queueName + ":"); } } catch (Exception e) { throw new MBeanException(e, "Error in deleting queue " + queueName + ". There was an issue with cluster coordination"); } finally { CurrentActor.remove(); } }
From source file:org.wso2.andes.server.information.management.QueueManagementInformationMBean.java
/** * {@inheritDoc}/*from w w w. ja va 2 s . c o m*/ */ @Override public void deleteAllMessagesInQueue( @MBeanOperationParameter(name = "queueName", description = "Name of the queue to delete messages from") String queueName, @MBeanOperationParameter(name = "ownerName", description = "Username of user that calls for " + "purge") String ownerName) throws MBeanException { AMQQueue queue = queueRegistry.getQueue(new AMQShortString(queueName)); try { if (queue == null) { throw new JMException("The Queue " + queueName + " is not a registered queue."); } queue.purge(0l); //This is to trigger the AMQChannel purge event so that the queue // state of qpid is updated. This method also validates the request owner and throws // an exception if permission is denied. InboundQueueEvent storageQueue = AMQPUtils.createInboundQueueEvent(queue); int purgedMessageCount = Andes.getInstance().purgeQueue(storageQueue); log.info("Total message count purged for queue (from store) : " + queueName + " : " + purgedMessageCount + ". All in memory messages received before the purge call" + " are abandoned from delivery phase. "); } catch (JMException jme) { if (jme.toString().contains("not a registered queue")) { throw new MBeanException(jme, "The Queue " + queueName + " is not a registered " + "queue."); } else { throw new MBeanException(jme, PURGE_QUEUE_ERROR + queueName); } } catch (AMQException | AndesException amqex) { throw new MBeanException(amqex, PURGE_QUEUE_ERROR + queueName); } }
From source file:org.wso2.andes.server.information.management.QueueManagementInformationMBean.java
/*** * {@inheritDoc}//from w ww . ja v a 2 s . c o m */ @Override public void restoreSelectedMessagesFromDeadLetterChannel( @MBeanOperationParameter(name = "andesMessageIds", description = "IDs of the Messages to Be restored") long[] andesMessageIds, @MBeanOperationParameter(name = "destinationQueueName", description = "Original destination queue of the messages") String destinationQueueName) throws MBeanException { if (null != andesMessageIds) { int movedMessageCount = -1; List<Long> andesMessageIdList = new ArrayList<>(andesMessageIds.length); Collections.addAll(andesMessageIdList, ArrayUtils.toObject(andesMessageIds)); try { movedMessageCount = moveMessagesFromDLCToNewDestination(andesMessageIdList, destinationQueueName, destinationQueueName, true); } catch (AndesException ex) { throw new MBeanException(ex, "Error occurred when restoring messages from DLC to original qeueue : " + destinationQueueName + " movedMessageCount : " + movedMessageCount); } } }
From source file:org.wso2.andes.server.information.management.QueueManagementInformationMBean.java
/*** * {@inheritDoc}/*w w w. j a v a 2 s . c o m*/ */ @Override public void rerouteSelectedMessagesFromDeadLetterChannel( @MBeanOperationParameter(name = "andesMessageIds", description = "IDs of the Messages to Be Restored") long[] andesMessageIds, @MBeanOperationParameter(name = "sourceQueue", description = "The original queue name of the messages") String sourceQueue, @MBeanOperationParameter(name = "targetQueue", description = "New destination queue for the messages") String targetQueue) throws MBeanException { if (null != andesMessageIds) { int movedMessageCount = -1; List<Long> andesMessageIdList = new ArrayList<>(andesMessageIds.length); Collections.addAll(andesMessageIdList, ArrayUtils.toObject(andesMessageIds)); try { movedMessageCount = moveMessagesFromDLCToNewDestination(andesMessageIdList, sourceQueue, targetQueue, false); } catch (AndesException ex) { throw new MBeanException(ex, "Error occurred when moving messages destined to sourceQueue : " + sourceQueue + " from DLC to targetQueue : " + targetQueue + ". movedMessageCount : " + movedMessageCount); } } }
From source file:org.wso2.andes.server.information.management.QueueManagementInformationMBean.java
/** * {@inheritDoc}/*from www . j a va 2 s. c om*/ */ @Override public CompositeData[] browseQueue( @MBeanOperationParameter(name = "queueName", description = "Name of queue to browse " + "messages") String queueName, @MBeanOperationParameter(name = "lastMsgId", description = "Browse message this message id " + "onwards") long nextMsgId, @MBeanOperationParameter(name = "maxMsgCount", description = "Maximum message count per " + "request") int maxMsgCount) throws MBeanException { List<CompositeData> compositeDataList = new ArrayList<>(); try { List<AndesMessageMetadata> nextNMessageMetadataFromQueue; if (!DLCQueueUtils.isDeadLetterQueue(queueName)) { nextNMessageMetadataFromQueue = Andes.getInstance().getNextNMessageMetadataFromQueue(queueName, nextMsgId, maxMsgCount); } else { nextNMessageMetadataFromQueue = Andes.getInstance().getNextNMessageMetadataFromDLC(queueName, nextMsgId, maxMsgCount); } return getDisplayableMetaData(nextNMessageMetadataFromQueue, true); } catch (AndesException e) { throw new MBeanException(e, "Error occurred in browse queue."); } }
From source file:org.wso2.andes.server.information.management.QueueManagementInformationMBean.java
/** * {@inheritDoc}/*from w w w.j av a2 s . co m*/ */ @Override public long getNumberOfMessagesInDLCForQueue(String queueName) throws MBeanException { try { return Andes.getInstance().getMessageCountInDLCForQueue(queueName, DLCQueueUtils.identifyTenantInformationAndGenerateDLCString(queueName)); } catch (AndesException e) { throw new MBeanException(e, "Error restoring messages from dead letter channel for:" + queueName); } }