-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CAMEL-21185: camel-management - ShutdownStrategy should be a MBean so…
… we can better define its JMX API. Also fix so all its attributes was exposed so you can configure timeout again. (#15471)
- Loading branch information
Showing
8 changed files
with
241 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...api/src/main/java/org/apache/camel/api/management/mbean/ManagedShutdownStrategyMBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.camel.api.management.mbean; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.apache.camel.api.management.ManagedAttribute; | ||
|
||
public interface ManagedShutdownStrategyMBean extends ManagedServiceMBean { | ||
|
||
@ManagedAttribute(description = "Shutdown timeout") | ||
void setTimeout(long timeout); | ||
|
||
@ManagedAttribute(description = "Shutdown timeout") | ||
long getTimeout(); | ||
|
||
@ManagedAttribute(description = "Shutdown timeout time unit") | ||
void setTimeUnit(TimeUnit timeUnit); | ||
|
||
@ManagedAttribute(description = "Shutdown timeout time unit") | ||
TimeUnit getTimeUnit(); | ||
|
||
@ManagedAttribute(description = "Whether Camel should try to suppress logging during shutdown and timeout was triggered, meaning forced shutdown is happening.") | ||
void setSuppressLoggingOnTimeout(boolean suppressLoggingOnTimeout); | ||
|
||
@ManagedAttribute(description = "Whether Camel should try to suppress logging during shutdown and timeout was triggered, meaning forced shutdown is happening.") | ||
boolean isSuppressLoggingOnTimeout(); | ||
|
||
@ManagedAttribute(description = "Whether to force shutdown of all consumers when a timeout occurred.") | ||
void setShutdownNowOnTimeout(boolean shutdownNowOnTimeout); | ||
|
||
@ManagedAttribute(description = "Whether to force shutdown of all consumers when a timeout occurred.") | ||
boolean isShutdownNowOnTimeout(); | ||
|
||
@ManagedAttribute(description = "Sets whether routes should be shutdown in reverse or the same order as they were started") | ||
void setShutdownRoutesInReverseOrder(boolean shutdownRoutesInReverseOrder); | ||
|
||
@ManagedAttribute(description = "Sets whether routes should be shutdown in reverse or the same order as they were started") | ||
boolean isShutdownRoutesInReverseOrder(); | ||
|
||
@ManagedAttribute(description = "Whether to log information about the inflight Exchanges which are still running during a shutdown which didn't complete without the given timeout.") | ||
void setLogInflightExchangesOnTimeout(boolean logInflightExchangesOnTimeout); | ||
|
||
@ManagedAttribute(description = "Whether to log information about the inflight Exchanges which are still running during a shutdown which didn't complete without the given timeout.") | ||
boolean isLogInflightExchangesOnTimeout(); | ||
|
||
@ManagedAttribute(description = "Whether the shutdown strategy is forcing to shutdown") | ||
boolean isForceShutdown(); | ||
|
||
@ManagedAttribute(description = "Whether a timeout has occurred during a shutdown.") | ||
boolean isTimeoutOccurred(); | ||
|
||
@ManagedAttribute(description = "logging level used for logging shutdown activity (such as starting and stopping routes). The default logging level is DEBUG.") | ||
String getLoggingLevel(); | ||
|
||
@ManagedAttribute(description = "logging level used for logging shutdown activity (such as starting and stopping routes). The default logging level is DEBUG.") | ||
void setLoggingLevel(String loggingLevel); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
...l-management/src/main/java/org/apache/camel/management/mbean/ManagedShutdownStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.camel.management.mbean; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.LoggingLevel; | ||
import org.apache.camel.api.management.ManagedResource; | ||
import org.apache.camel.api.management.mbean.ManagedShutdownStrategyMBean; | ||
import org.apache.camel.spi.ShutdownStrategy; | ||
|
||
@ManagedResource(description = "Managed ShutdownStrategy") | ||
public class ManagedShutdownStrategy extends ManagedService implements ManagedShutdownStrategyMBean { | ||
|
||
private final ShutdownStrategy strategy; | ||
|
||
public ManagedShutdownStrategy(CamelContext context, ShutdownStrategy controller) { | ||
super(context, controller); | ||
this.strategy = controller; | ||
} | ||
|
||
public ShutdownStrategy getShutdownStrategy() { | ||
return strategy; | ||
} | ||
|
||
@Override | ||
public void setTimeout(long timeout) { | ||
strategy.setTimeout(timeout); | ||
} | ||
|
||
@Override | ||
public long getTimeout() { | ||
return strategy.getTimeout(); | ||
} | ||
|
||
@Override | ||
public void setTimeUnit(TimeUnit timeUnit) { | ||
strategy.setTimeUnit(timeUnit); | ||
} | ||
|
||
@Override | ||
public TimeUnit getTimeUnit() { | ||
return strategy.getTimeUnit(); | ||
} | ||
|
||
@Override | ||
public void setSuppressLoggingOnTimeout(boolean suppressLoggingOnTimeout) { | ||
strategy.setSuppressLoggingOnTimeout(suppressLoggingOnTimeout); | ||
} | ||
|
||
@Override | ||
public boolean isSuppressLoggingOnTimeout() { | ||
return strategy.isSuppressLoggingOnTimeout(); | ||
} | ||
|
||
@Override | ||
public void setShutdownNowOnTimeout(boolean shutdownNowOnTimeout) { | ||
strategy.setShutdownNowOnTimeout(shutdownNowOnTimeout); | ||
} | ||
|
||
@Override | ||
public boolean isShutdownNowOnTimeout() { | ||
return strategy.isShutdownNowOnTimeout(); | ||
} | ||
|
||
@Override | ||
public void setShutdownRoutesInReverseOrder(boolean shutdownRoutesInReverseOrder) { | ||
strategy.setShutdownRoutesInReverseOrder(shutdownRoutesInReverseOrder); | ||
} | ||
|
||
@Override | ||
public boolean isShutdownRoutesInReverseOrder() { | ||
return strategy.isShutdownRoutesInReverseOrder(); | ||
} | ||
|
||
@Override | ||
public void setLogInflightExchangesOnTimeout(boolean logInflightExchangesOnTimeout) { | ||
strategy.setLogInflightExchangesOnTimeout(logInflightExchangesOnTimeout); | ||
} | ||
|
||
@Override | ||
public boolean isLogInflightExchangesOnTimeout() { | ||
return strategy.isLogInflightExchangesOnTimeout(); | ||
} | ||
|
||
@Override | ||
public boolean isForceShutdown() { | ||
return strategy.isForceShutdown(); | ||
} | ||
|
||
@Override | ||
public boolean isTimeoutOccurred() { | ||
return strategy.isTimeoutOccurred(); | ||
} | ||
|
||
@Override | ||
public String getLoggingLevel() { | ||
return strategy.getLoggingLevel().toString(); | ||
} | ||
|
||
@Override | ||
public void setLoggingLevel(String loggingLevel) { | ||
strategy.setLoggingLevel(LoggingLevel.valueOf(loggingLevel)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters