001    /*
002     * Copyright 2009 Red Hat, Inc.
003     * Red Hat licenses this file to you under the Apache License, version
004     * 2.0 (the "License"); you may not use this file except in compliance
005     * with the License.  You may obtain a copy of the License at
006     *    http://www.apache.org/licenses/LICENSE-2.0
007     * Unless required by applicable law or agreed to in writing, software
008     * distributed under the License is distributed on an "AS IS" BASIS,
009     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
010     * implied.  See the License for the specific language governing
011     * permissions and limitations under the License.
012     */
013    
014    package org.hornetq.api.core.management;
015    
016    import javax.management.MBeanOperationInfo;
017    
018    import org.hornetq.api.core.HornetQException;
019    import org.hornetq.api.core.Interceptor;
020    
021    /**
022     * A HornetQServerControl is used to manage HornetQ servers.
023     */
024    public interface HornetQServerControl
025    {
026       // Attributes ----------------------------------------------------
027    
028       /**
029        * Returns the name of the connector used to connect to the live.
030        * <br>
031        * If this server is not a backup that uses shared nothing HA, it's value is null
032        */
033       String getLiveConnectorName() throws Exception;
034    
035       /**
036        * Returns this server's version.
037        */
038       String getVersion();
039    
040       /**
041        * Returns the number of connections connected to this server.
042        */
043       int getConnectionCount();
044    
045       /**
046        * Return whether this server is started.
047        */
048       boolean isStarted();
049    
050       /**
051        * Returns the list of interceptors used by this server.
052        *
053        * @see Interceptor
054        */
055       String[] getInterceptorClassNames();
056    
057       /**
058        * Returns whether this server is clustered.
059        */
060       boolean isClustered();
061    
062       /**
063        * Returns the maximum number of threads in the <em>scheduled</em> thread pool.
064        */
065       int getScheduledThreadPoolMaxSize();
066    
067       /**
068        * Returns the maximum number of threads in the thread pool.
069        */
070       int getThreadPoolMaxSize();
071    
072       /**
073        * Returns the interval time (in milliseconds) to invalidate security credentials.
074        */
075       long getSecurityInvalidationInterval();
076    
077       /**
078        * Returns whether security is enabled for this server.
079        */
080       boolean isSecurityEnabled();
081    
082       /**
083        * Returns the file system directory used to store bindings.
084        */
085       String getBindingsDirectory();
086    
087       /**
088        * Returns the file system directory used to store journal log.
089        */
090       String getJournalDirectory();
091    
092       /**
093        * Returns the type of journal used by this server (either {@code NIO} or {@code ASYNCIO}).
094        */
095       String getJournalType();
096    
097       /**
098        * Returns whether the journal is synchronized when receiving transactional data.
099        */
100       boolean isJournalSyncTransactional();
101    
102       /**
103        * Returns whether the journal is synchronized when receiving non-transactional data.
104        */
105       boolean isJournalSyncNonTransactional();
106    
107       /**
108        * Returns the size (in bytes) of each journal files.
109        */
110       int getJournalFileSize();
111    
112       /**
113        * Returns the number of journal files to pre-create.
114        */
115       int getJournalMinFiles();
116    
117       /**
118        * Returns the maximum number of write requests that can be in the AIO queue at any given time.
119        */
120       int getJournalMaxIO();
121    
122       /**
123        * Returns the size of the internal buffer on the journal.
124        */
125       int getJournalBufferSize();
126    
127       /**
128        * Returns the timeout (in nanoseconds) used to flush internal buffers on the journal.
129        */
130       int getJournalBufferTimeout();
131    
132       /**
133        * do any clients failover on a server shutdown
134        */
135       void setFailoverOnServerShutdown(boolean failoverOnServerShutdown) throws Exception;
136    
137    
138       /**
139        * returns if clients failover on a server shutdown
140        */
141       boolean isFailoverOnServerShutdown();
142    
143       /**
144        * Returns the minimal number of journal files before compacting.
145        */
146       int getJournalCompactMinFiles();
147    
148       /**
149        * Return the percentage of live data before compacting the journal.
150        */
151       int getJournalCompactPercentage();
152    
153       /**
154        * Returns whether this server is using persistence and store data.
155        */
156       boolean isPersistenceEnabled();
157    
158       /**
159        * Returns whether the bindings directory is created on this server startup.
160        */
161       boolean isCreateBindingsDir();
162    
163       /**
164        * Returns whether the journal directory is created on this server startup.
165        */
166       boolean isCreateJournalDir();
167    
168       /**
169        * Returns whether message counter is enabled for this server.
170        */
171       boolean isMessageCounterEnabled();
172    
173       /**
174        * Returns the maximum number of days kept in memory for message counter.
175        */
176       int getMessageCounterMaxDayCount();
177    
178       /**
179        * Sets the maximum number of days kept in memory for message counter.
180        *
181        * @param count value must be greater than 0
182        */
183       void setMessageCounterMaxDayCount(int count) throws Exception;
184    
185       /**
186        * Returns the sample period (in milliseconds) to take message counter snapshot.
187        */
188       long getMessageCounterSamplePeriod();
189    
190       /**
191        * Sets the sample period to take message counter snapshot.
192        *
193        * @param newPeriod value must be greater than 1000ms
194        */
195       void setMessageCounterSamplePeriod(long newPeriod) throws Exception;
196    
197       /**
198        * Returns {@code true} if this server is a backup, {@code false} if it is a live server.
199        * <br>
200        * If a backup server has been activated, returns {@code false}.
201        */
202       boolean isBackup();
203    
204       /**
205        * Returns whether this server shares its data store with a corresponding live or backup server.
206        */
207       boolean isSharedStore();
208    
209       /**
210        * Returns the file system directory used to store paging files.
211        */
212       String getPagingDirectory();
213    
214       /**
215        * Returns whether delivery count is persisted before messages are delivered to the consumers.
216        */
217       boolean isPersistDeliveryCountBeforeDelivery();
218    
219       /**
220        * Returns the connection time to live.
221        * <br>
222        * This value overrides the connection time to live <em>sent by the client</em>.
223        */
224       long getConnectionTTLOverride();
225    
226       /**
227        * Returns the management address of this server.
228        * <br>
229        * Clients can send management messages to this address to manage this server.
230        */
231       String getManagementAddress();
232    
233       /**
234        * Returns the management notification address of this server.
235        * <br>
236        * Clients can bind queues to this address to receive management notifications emitted by this server.
237        */
238       String getManagementNotificationAddress();
239    
240       /**
241        * Returns the size of the cache for pre-creating message IDs.
242        */
243       int getIDCacheSize();
244    
245       /**
246        * Returns whether message ID cache is persisted.
247        */
248       boolean isPersistIDCache();
249    
250       /**
251        * Returns the file system directory used to store large messages.
252        */
253       String getLargeMessagesDirectory();
254    
255       /**
256        * Returns whether wildcard routing is supported by this server.
257        */
258       boolean isWildcardRoutingEnabled();
259    
260       /**
261        * Returns the timeout (in milliseconds) after which transactions is removed
262        * from the resource manager after it was created.
263        */
264       long getTransactionTimeout();
265    
266       /**
267        * Returns the frequency (in milliseconds)  to scan transactions to detect which transactions
268        * have timed out.
269        */
270       long getTransactionTimeoutScanPeriod();
271    
272       /**
273        * Returns the frequency (in milliseconds)  to scan messages to detect which messages
274        * have expired.
275        */
276       long getMessageExpiryScanPeriod();
277    
278       /**
279        * Returns the priority of the thread used to scan message expiration.
280        */
281       long getMessageExpiryThreadPriority();
282    
283       /**
284        * Returns whether code coming from connection is executed asynchronously or not.
285        */
286       boolean isAsyncConnectionExecutionEnabled();
287    
288       /**
289        * Returns the connectors configured for this server.
290        */
291       Object[] getConnectors() throws Exception;
292    
293       /**
294        * Returns the connectors configured for this server using JSON serialization.
295        */
296       String getConnectorsAsJSON() throws Exception;
297    
298       /**
299        * Returns the addresses created on this server.
300        */
301       String[] getAddressNames();
302    
303       /**
304        * Returns the names of the queues created on this server.
305        */
306       String[] getQueueNames();
307    
308       // Operations ----------------------------------------------------
309    
310       /**
311        * Create a durable queue.
312        * <br>
313        * This method throws a {@link HornetQException#QUEUE_EXISTS}) exception if the queue already exits.
314        *
315        * @param address address to bind the queue to
316        * @param name name of the queue
317        */
318       @Operation(desc = "Create a queue with the specified address", impact = MBeanOperationInfo.ACTION)
319       void createQueue(@Parameter(name = "address", desc = "Address of the queue") String address,
320                        @Parameter(name = "name", desc = "Name of the queue") String name) throws Exception;
321    
322       /**
323        * Create a queue.
324        * <br>
325        * This method throws a {@link HornetQException#QUEUE_EXISTS}) exception if the queue already exits.
326        *
327        * @param address address to bind the queue to
328        * @param name name of the queue
329        * @param filter of the queue
330        * @param durable whether the queue is durable
331        */
332       @Operation(desc = "Create a queue", impact = MBeanOperationInfo.ACTION)
333       void createQueue(@Parameter(name = "address", desc = "Address of the queue") String address,
334                        @Parameter(name = "name", desc = "Name of the queue") String name,
335                        @Parameter(name = "filter", desc = "Filter of the queue") String filter,
336                        @Parameter(name = "durable", desc = "Is the queue durable?") boolean durable) throws Exception;
337    
338       /**
339        * Create a queue.
340        * <br>
341        * This method throws a {@link HornetQException#QUEUE_EXISTS}) exception if the queue already exits.
342        *
343        * @param address address to bind the queue to
344        * @param name name of the queue
345        * @param durable whether the queue is durable
346        */
347       @Operation(desc = "Create a queue with the specified address, name and durability", impact = MBeanOperationInfo.ACTION)
348       void createQueue(@Parameter(name = "address", desc = "Address of the queue") String address,
349                        @Parameter(name = "name", desc = "Name of the queue") String name,
350                        @Parameter(name = "durable", desc = "Is the queue durable?") boolean durable) throws Exception;
351    
352       /**
353        * Deploy a durable queue.
354        * <br>
355        * This method will do nothing if the queue with the given name already exists on the server.
356        *
357        * @param address address to bind the queue to
358        * @param name name of the queue
359        * @param filter of the queue
360        */
361       @Operation(desc = "Deploy a queue", impact = MBeanOperationInfo.ACTION)
362       void deployQueue(@Parameter(name = "address", desc = "Address of the queue") String address,
363                        @Parameter(name = "name", desc = "Name of the queue") String name,
364                        @Parameter(name = "filter", desc = "Filter of the queue")String filter) throws Exception;
365    
366       /**
367        * Deploy a queue.
368        * <br>
369        * This method will do nothing if the queue with the given name already exists on the server.
370        *
371        * @param address address to bind the queue to
372        * @param name name of the queue
373        * @param filter of the queue
374        * @param durable whether the queue is durable
375        */
376       @Operation(desc = "Deploy a queue", impact = MBeanOperationInfo.ACTION)
377       void deployQueue(@Parameter(name = "address", desc = "Address of the queue") String address,
378                        @Parameter(name = "name", desc = "Name of the queue") String name,
379                        @Parameter(name = "filter", desc = "Filter of the queue") String filter,
380                        @Parameter(name = "durable", desc = "Is the queue durable?") boolean durable) throws Exception;
381    
382       /**
383        * Destroys the queue corresponding to the specified name.
384        */
385       @Operation(desc = "Destroy a queue", impact = MBeanOperationInfo.ACTION)
386       void destroyQueue(@Parameter(name = "name", desc = "Name of the queue to destroy") String name) throws Exception;
387    
388       /**
389        * Enables message counters for this server.
390        */
391       @Operation(desc = "Enable message counters", impact = MBeanOperationInfo.ACTION)
392       void enableMessageCounters() throws Exception;
393    
394       /**
395        * Disables message counters for this server.
396        */
397       @Operation(desc = "Disable message counters", impact = MBeanOperationInfo.ACTION)
398       void disableMessageCounters() throws Exception;
399    
400       /**
401        * Reset all message counters.
402        */
403       @Operation(desc = "Reset all message counters", impact = MBeanOperationInfo.ACTION)
404       void resetAllMessageCounters() throws Exception;
405    
406       /**
407        * Reset histories for all message counters.
408        */
409       @Operation(desc = "Reset all message counters history", impact = MBeanOperationInfo.ACTION)
410       void resetAllMessageCounterHistories() throws Exception;
411    
412       /**
413        * List all the prepared transaction, sorted by date, oldest first.
414        * <br>
415        * The Strings are Base-64 representation of the transaction XID and can be
416        * used to heuristically commit or rollback the transactions.
417        *
418        * @see #commitPreparedTransaction(String)
419        * @see #rollbackPreparedTransaction(String)
420        */
421       @Operation(desc = "List all the prepared transaction, sorted by date, oldest first")
422       String[] listPreparedTransactions() throws Exception;
423    
424       /**
425        * List all the prepared transaction, sorted by date,
426        * oldest first, with details, in text format.
427        */
428       @Operation(desc = "List all the prepared transaction, sorted by date, oldest first, with details, in JSON format")
429       String listPreparedTransactionDetailsAsJSON() throws Exception;
430    
431       /**
432        * List all the prepared transaction, sorted by date,
433        * oldest first, with details, in HTML format
434        */
435       @Operation(desc = "List all the prepared transaction, sorted by date, oldest first, with details, in HTML format")
436       String listPreparedTransactionDetailsAsHTML() throws Exception;
437    
438       /**
439        * List transactions which have been heuristically committed.
440        */
441       String[] listHeuristicCommittedTransactions() throws Exception;
442    
443       /**
444        * List transactions which have been heuristically rolled back.
445        */
446       String[] listHeuristicRolledBackTransactions() throws Exception;
447    
448       /**
449        * Heuristically commits a prepared transaction.
450        *
451        * @param transactionAsBase64 base 64 representation of a prepare transaction
452        * @return {@code true} if the transaction was successfully committed, {@code false} else
453        *
454        * @see #listPreparedTransactions()
455        */
456       @Operation(desc = "Commit a prepared transaction")
457       boolean commitPreparedTransaction(@Parameter(desc = "the Base64 representation of a transaction", name = "transactionAsBase64") String transactionAsBase64) throws Exception;
458    
459       /**
460        * Heuristically rolls back a prepared transaction.
461        *
462        * @param transactionAsBase64 base 64 representation of a prepare transaction
463        * @return {@code true} if the transaction was successfully rolled back, {@code false} else
464        *
465        * @see #listPreparedTransactions()
466        */
467       @Operation(desc = "Rollback a prepared transaction")
468       boolean rollbackPreparedTransaction(@Parameter(desc = "the Base64 representation of a transaction", name = "transactionAsBase64") String transactionAsBase64) throws Exception;
469    
470       /**
471        * Lists the addresses of all the clients connected to this address.
472        */
473       @Operation(desc = "List the client addresses", impact = MBeanOperationInfo.INFO)
474       String[] listRemoteAddresses() throws Exception;
475    
476       /**
477        * Lists the addresses of the clients connected to this address which matches the specified IP address.
478        */
479       @Operation(desc = "List the client addresses which match the given IP Address", impact = MBeanOperationInfo.INFO)
480       String[] listRemoteAddresses(@Parameter(desc = "an IP address", name = "ipAddress") String ipAddress) throws Exception;
481    
482       /**
483        * Closes all the connections of clients connected to this server which matches the specified IP address.
484        */
485       @Operation(desc = "Closes all the connections for the given IP Address", impact = MBeanOperationInfo.INFO)
486       boolean closeConnectionsForAddress(@Parameter(desc = "an IP address", name = "ipAddress") String ipAddress) throws Exception;
487    
488       /**
489        * Lists all the IDs of the connections connected to this server.
490        */
491       @Operation(desc = "List all the connection IDs", impact = MBeanOperationInfo.INFO)
492       String[] listConnectionIDs() throws Exception;
493    
494       String listProducersInfoAsJSON() throws Exception;
495    
496       /**
497        * Lists all the sessions IDs for the specified connection ID.
498        */
499       @Operation(desc = "List the sessions for the given connectionID", impact = MBeanOperationInfo.INFO)
500       String[] listSessions(@Parameter(desc = "a connection ID", name = "connectionID") String connectionID) throws Exception;
501    
502       /**
503        * This method is used by HornetQ clustering and must not be called by HornetQ clients.
504        */
505       void sendQueueInfoToQueue(String queueName, String address) throws Exception;
506    
507       @Operation(desc= "Add security settings for addresses matching the addressMatch", impact = MBeanOperationInfo.ACTION)
508       void addSecuritySettings(
509                                @Parameter(desc="an address match", name="addressMatch") String addressMatch,
510                                @Parameter(desc="a comma-separated list of roles allowed to send messages", name="send") String sendRoles,
511                                @Parameter(desc="a comma-separated list of roles allowed to consume messages", name="consume") String consumeRoles,
512                                @Parameter(desc="a comma-separated list of roles allowed to create durable queues", name="createDurableQueueRoles") String createDurableQueueRoles,
513                                @Parameter(desc="a comma-separated list of roles allowed to delete durable queues", name="deleteDurableQueueRoles") String deleteDurableQueueRoles,
514                                @Parameter(desc="a comma-separated list of roles allowed to create non durable queues", name="createNonDurableQueueRoles") String createNonDurableQueueRoles,
515                                @Parameter(desc="a comma-separated list of roles allowed to delete non durable queues", name="deleteNonDurableQueueRoles") String deleteNonDurableQueueRoles,
516                                @Parameter(desc="a comma-separated list of roles allowed to send management messages messages", name="manage") String manageRoles) throws Exception;
517    
518       @Operation(desc = "Remove security settings for an address", impact = MBeanOperationInfo.ACTION)
519       void removeSecuritySettings(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch) throws Exception;
520    
521       @Operation(desc = "get roles for a specific address match", impact = MBeanOperationInfo.INFO)
522       Object[] getRoles(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch) throws Exception;
523    
524       @Operation(desc = "get roles (as a JSON string) for a specific address match", impact = MBeanOperationInfo.INFO)
525       String getRolesAsJSON(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch) throws Exception;
526    
527          /**
528        * adds a new address setting for a specific address
529        */
530       @Operation(desc= "Add address settings for addresses matching the addressMatch", impact = MBeanOperationInfo.ACTION)
531       void addAddressSettings(@Parameter(desc="an address match", name="addressMatch") String addressMatch,
532                               @Parameter(desc="the dead letter address setting", name="DLA") String DLA,
533                               @Parameter(desc="the expiry address setting", name="expiryAddress") String expiryAddress,
534                               @Parameter(desc="are any queues created for this address a last value queue", name="lastValueQueue") boolean lastValueQueue,
535                               @Parameter(desc="the delivery attempts", name="deliveryAttempts") int deliveryAttempts,
536                               @Parameter(desc="the max size in bytes", name="maxSizeBytes") long maxSizeBytes,
537                               @Parameter(desc="the page size in bytes", name="pageSizeBytes") int pageSizeBytes,
538                               @Parameter(desc="the max number of pages in the soft memory cache", name="pageMaxCacheSize") int pageMaxCacheSize,
539                               @Parameter(desc="the redelivery delay", name="redeliveryDelay") long redeliveryDelay,
540                               @Parameter(desc="the redistribution delay", name="redistributionDelay") long redistributionDelay,
541                               @Parameter(desc="do we send to the DLA when there is no where to route the message", name="sendToDLAOnNoRoute") boolean sendToDLAOnNoRoute,
542                               @Parameter(desc="the ploicy to use when the address is full", name="addressFullMessagePolicy") String addressFullMessagePolicy) throws Exception;
543    
544       void removeAddressSettings(String addressMatch) throws Exception;
545    
546       /**
547        * returns the address settings as a JSON string
548        */
549       @Operation(desc = "returns the address settings as a JSON string for an address match", impact = MBeanOperationInfo.INFO)
550       String getAddressSettingsAsJSON(@Parameter(desc="an address match", name="addressMatch") String addressMatch) throws Exception;
551    
552       String[] getDivertNames();
553    
554       @Operation(desc= "Create a Divert", impact = MBeanOperationInfo.ACTION)
555       void createDivert(@Parameter(name="name", desc="Name of the divert") String name,
556                         @Parameter(name="routingName", desc="Routing name of the divert") String routingName,
557                         @Parameter(name="address", desc="Address to divert from") String address,
558                         @Parameter(name="forwardingAddress", desc="Adress to divert to") String forwardingAddress,
559                         @Parameter(name="exclusive", desc="Is the divert exclusive?") boolean exclusive,
560                         @Parameter(name="filterString", desc="Filter of the divert") String filterString,
561                         @Parameter(name="transformerClassName", desc="Class name of the divert's transformer") String transformerClassName) throws Exception;
562    
563       @Operation(desc= "Destroy a Divert", impact = MBeanOperationInfo.ACTION)
564       void destroyDivert(@Parameter(name="name", desc="Name of the divert") String name) throws Exception;
565    
566       String[] getBridgeNames();
567    
568       @Operation(desc= "Create a Bridge", impact = MBeanOperationInfo.ACTION)
569       void createBridge(@Parameter(name="name", desc="Name of the bridge") String name,
570                         @Parameter(name="queueName", desc="Name of the source queue") String queueName,
571                         @Parameter(name="forwardingAddress", desc="Forwarding address") String forwardingAddress,
572                         @Parameter(name="filterString", desc="Filter of the brdige") String filterString,
573                         @Parameter(name="transformerClassName", desc="Class name of the bridge transformer") String transformerClassName,
574                         @Parameter(name="retryInterval", desc="Connection retry interval") long retryInterval,
575                         @Parameter(name="retryIntervalMultiplier", desc="Connection retry interval multiplier") double retryIntervalMultiplier,
576                         @Parameter(name="reconnectAttempts", desc="Number of reconnection attempts") int reconnectAttempts,
577                         @Parameter(name="useDuplicateDetection", desc="Use duplicate detection") boolean useDuplicateDetection,
578                         @Parameter(name="confirmationWindowSize", desc="Confirmation window size") int confirmationWindowSize,
579                         @Parameter(name="clientFailureCheckPeriod", desc="Period to check client failure") long clientFailureCheckPeriod,
580                         @Parameter(name="staticConnectorNames", desc="comma separated list of connector names or name of discovery group if 'useDiscoveryGroup' is set to true") String connectorNames,
581                         @Parameter(name="useDiscoveryGroup", desc="use discovery  group")boolean useDiscoveryGroup,
582                         @Parameter(name="ha", desc="Is it using HA") boolean ha,
583                         @Parameter(name="user", desc="User name") String user,
584                         @Parameter(name="password", desc="User password") String password) throws Exception;
585    
586    
587       @Operation(desc= "Destroy a bridge", impact = MBeanOperationInfo.ACTION)
588       void destroyBridge(@Parameter(name="name", desc="Name of the bridge") String name) throws Exception;
589    
590       @Operation(desc = "force the server to stop and notify clients to failover", impact = MBeanOperationInfo.UNKNOWN)
591       void forceFailover() throws Exception;
592    }