org.springframework.jmx.export.annotation.ManagedOperationParameter Java Examples

The following examples show how to use org.springframework.jmx.export.annotation.ManagedOperationParameter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BankMoneyTransferService.java    From Hands-On-High-Performance-with-Spring-5 with MIT License 6 votes vote down vote up
@ManagedOperation(description = "Amount transfer")
@ManagedOperationParameters({
		@ManagedOperationParameter(name = "sourceAccount", description = "Transfer from account"),
		@ManagedOperationParameter(name = "destinationAccount", description = "Transfer to account"),
		@ManagedOperationParameter(name = "transferAmount", description = "Amount to be transfer") })
public void transfer(String sourceAccount, String destinationAccount, int transferAmount) {
	if (transferAmount == 0) {
		throw new IllegalArgumentException("Invalid amount");
	}
	int sourceAcctBalance = accountMap.get(sourceAccount);
	int destinationAcctBalance = accountMap.get(destinationAccount);

	if ((sourceAcctBalance - transferAmount) < 0) {
		throw new IllegalArgumentException("Not enough balance.");
	}
	sourceAcctBalance = sourceAcctBalance - transferAmount;
	destinationAcctBalance = destinationAcctBalance + transferAmount;

	accountMap.put(sourceAccount, sourceAcctBalance);
	accountMap.put(destinationAccount, destinationAcctBalance);
}
 
Example #2
Source File: LoggerConfigurator.java    From maven-framework-project with MIT License 6 votes vote down vote up
@ManagedOperation(description = "Set Logger Level")
@ManagedOperationParameters({
		@ManagedOperationParameter(description = "The Logger Name", name = "loggerName"),
		@ManagedOperationParameter(description = "The Level to which the Logger must be set", name = "loggerLevel") })
public void setLoggerLevel(String loggerName, String loggerLevel) {

	Logger thisLogger = Logger.getLogger(this.getClass());
	thisLogger.setLevel(Level.INFO);

	Logger logger = Logger.getLogger(loggerName);

	logger.setLevel(Level.toLevel(loggerLevel, Level.INFO));

	thisLogger.info("Set logger " + loggerName + " to level "
			+ logger.getLevel());

}
 
Example #3
Source File: ModelFactoryImpl.java    From FX-AlgorithmTrading with MIT License 6 votes vote down vote up
@Override
@ManagedOperation
@ManagedOperationParameters({
        @ManagedOperationParameter(name = "modelTypeStr", description = "value of ModelType.name()"),
        @ManagedOperationParameter(name = "modelVersionStr", description = "value of ModelVersion.name()"),
        @ManagedOperationParameter(name = "symbolStr", description = "value of Symbol.name()") })
public String deployModelJMX(String modelTypeStr, String modelVersionStr, String symbolStr) {
    try {
        ModelType modelType = ModelType.valueOf(modelTypeStr);
        Symbol symbol = Symbol.valueOf(symbolStr);
        // deploy
        IModel model = deployModel(modelType, modelVersionStr, symbol);
        return String.format("Successfully deploy model : %s", model.getModelInformation());
    } catch (ModelInitializeException e) {
        return String.format("Failed to depoly model : %s, %s, %s \n\n%s", modelTypeStr, modelVersionStr, symbolStr, ExceptionUtility.getStackTraceString(e));
    }
}
 
Example #4
Source File: IndicatorManagerImpl.java    From FX-AlgorithmTrading with MIT License 6 votes vote down vote up
/**
 * Indicatorを表示します
 */
@ManagedOperation
@ManagedOperationParameters({
    @ManagedOperationParameter(name = "indicatorTypeStr", description = "IndicatorType.name()"),
    @ManagedOperationParameter(name = "symbolStr", description = "Symbol.name()"),
    @ManagedOperationParameter(name = "periodStr", description = "Period.name()")})
public String showIndicator(String indicatorTypeStr, String symbolStr, String periodStr) {
    try {
        IndicatorType indicatorType = IndicatorType.valueOf(indicatorTypeStr);
        Symbol symbol = Symbol.valueOf(symbolStr);
        Period period = Period.valueOf(periodStr);
        String indicatorStr = indicatorDataHolder.getIndicator(indicatorType, symbol, period).getDataString();
        return String.format("%s-%s-%s %s", indicatorType.name(), symbol.name(), period.name(), indicatorStr);
    } catch (Exception e) {
        return String.format("Failed to Execute : %s, %s, %s \n\n%s", indicatorTypeStr, symbolStr, periodStr, ExceptionUtility.getStackTraceString(e));
    }
}
 
Example #5
Source File: MemoryWarningServiceConfigurator.java    From maven-framework-project with MIT License 5 votes vote down vote up
@ManagedOperation(description = "Sets the memory threshold for the memory warning system")
@ManagedOperationParameters({ @ManagedOperationParameter(description = "The memory threshold", name = "memoryThreshold"), })
public void setMemoryThreshold(double memoryThreshold) {

	MemoryWarningService memoryWarningService = (MemoryWarningService) ctx
			.getBean("memoryWarningService");
	memoryWarningService.setPercentageUsageThreshold(memoryThreshold);

	LOG.info("Memory threshold set to " + memoryThreshold);
}
 
Example #6
Source File: Calculator.java    From thinking-in-spring-boot-samples with Apache License 2.0 5 votes vote down vote up
@ManagedOperation(description = "加法操作")
@ManagedOperationParameters({
        @ManagedOperationParameter(name = "a", description = "加数"),
        @ManagedOperationParameter(name = "b", description = "被加数")})
public int add(int a, int b) {
    return a + b;
}
 
Example #7
Source File: LoggerConfigurator.java    From maven-framework-project with MIT License 5 votes vote down vote up
@ManagedOperation(description = "Returns the Logger LEVEL for the given logger name")
@ManagedOperationParameters({ @ManagedOperationParameter(description = "The Logger Name", name = "loggerName"), })
public String getLoggerLevel(String loggerName) {

	Logger logger = Logger.getLogger(loggerName);
	Level loggerLevel = logger.getLevel();

	return loggerLevel == null ? "The logger " + loggerName
			+ " has not level" : loggerLevel.toString();

}
 
Example #8
Source File: PieceService.java    From computoser with GNU Affero General Public License v3.0 5 votes vote down vote up
@ManagedOperation
@Async
public void rerenderMp3(@ManagedOperationParameter(description = "", name = "fromId") int fromId,
        @ManagedOperationParameter(description = "", name = "toId") int toId) {
    for (int i = fromId; i <= toId; i++) {
        try (InputStream is = fileStorageService.getFile(getMidiFilePath(i))) {
            byte[] midi = IOUtils.toByteArray(is);
            byte[] mp3 = generator.toMp3(midi);
            fileStorageService.storeFile(getMp3FilePath(i), mp3);
        } catch (Exception ex) {
            logger.warn("Error rerendering midi with id=" + i);
        }
    }
}
 
Example #9
Source File: ModelFactoryImpl.java    From FX-AlgorithmTrading with MIT License 5 votes vote down vote up
@Override
@ManagedOperation
@ManagedOperationParameters({
        @ManagedOperationParameter(name = "modelClassName", description = "class name of IndicatorTradeModel-SubModel"),
        @ManagedOperationParameter(name = "versionName", description = "version name"),
        @ManagedOperationParameter(name = "symbolStr", description = "Symbol.name()") })
public String deployIndicatorTradeModelJMX(String modelClassName, String versionName, String symbolStr) {
    try {
        Symbol symbol = Symbol.valueOf(symbolStr);
        IModel model = deployIndicatorTradeModel(modelClassName, versionName, symbol);
        return String.format("Successfully deploy model : %s", model.getModelInformation());
    } catch (ModelInitializeException e) {
        return String.format("Failed to depoly model : %s, %s, %s \n\n%s", modelClassName, versionName, symbolStr, ExceptionUtility.getStackTraceString(e));
    }
}
 
Example #10
Source File: ModelFactoryImpl.java    From FX-AlgorithmTrading with MIT License 5 votes vote down vote up
/**
 * NoiseRangeModelモデルを配備します
 *
 * @return
 */
@ManagedOperation
@ManagedOperationParameters({
        @ManagedOperationParameter(name = "modelVersionStr", description = "ModelVersion.name()"),
        @ManagedOperationParameter(name = "symbolStr", description = "Symbol.name()") })
public String deployModelNoiseRangeModel(String modelVersionStr, String symbolStr) {
    return deployModelJMX(ModelType.NOISE_RANGE.name(), modelVersionStr, symbolStr);
}
 
Example #11
Source File: EventGenaratorImpl.java    From FX-AlgorithmTrading with MIT License 5 votes vote down vote up
@Override
@ManagedOperation(description="Logout from selected market")
@ManagedOperationParameter(name = "marketTypeName", description = "MarketType.name()")
public String logoutMarket(String marketTypeName) {
    try {
        MarketType marketType = MarketType.valueOf(marketTypeName);
        informationManager.sendEvent(new SystemInformationEvent(uuid, getClass(), SystemInfromationType.MARKET_LOGOUT, marketType.name(), null));
    } catch (Exception e) {
        return "Failed send logout to " + marketTypeName + ".\n\n" + ExceptionUtility.getStackTraceString(e);
    }
    return "Successfully send logout to " + marketTypeName;
}
 
Example #12
Source File: EventGenaratorImpl.java    From FX-AlgorithmTrading with MIT License 5 votes vote down vote up
@Override
@ManagedOperation(description="Login to selected market")
@ManagedOperationParameter(name = "marketTypeName", description = "MarketType.name()")
public String loginMarket(String marketTypeName) {
    try {
        MarketType marketType = MarketType.valueOf(marketTypeName);
        informationManager.sendEvent(new SystemInformationEvent(uuid, getClass(), SystemInfromationType.MARKET_LOGIN, marketType.name(), null));
    } catch (Exception e) {
        return "Failed send login to " + marketTypeName + ".\n\n" + ExceptionUtility.getStackTraceString(e);
    }
    return "Successfully send login to " + marketTypeName;
}
 
Example #13
Source File: PersistenceManagerMBean.java    From cuba with Apache License 2.0 5 votes vote down vote up
/**
 * Manually update statistics for an entity.
 */
@ManagedOperation(description = "Enter statistics for the specified entity")
@ManagedOperationParameters({
        @ManagedOperationParameter(name = "entityName", description = "MetaClass name, e.g. sec$User"),
        @ManagedOperationParameter(name = "instanceCount", description = ""),
        @ManagedOperationParameter(name = "fetchUI", description = ""),
        @ManagedOperationParameter(name = "maxFetchUI", description = ""),
        @ManagedOperationParameter(name = "lazyCollectionThreshold", description = ""),
        @ManagedOperationParameter(name = "lookupScreenThreshold", description = "")
})
String enterStatistics(String entityName, Long instanceCount, Integer fetchUI, Integer maxFetchUI,
                       Integer lazyCollectionThreshold, Integer lookupScreenThreshold);
 
Example #14
Source File: PersistenceManagerMBean.java    From cuba with Apache License 2.0 5 votes vote down vote up
/**
 * Execute a JPQL update statement.
 * @param queryString   JPQL update statement
 * @param softDeletion  soft deletion sign
 * @return              number of entity instances affected by update
 */
@ManagedOperation(description = "Execute a JPQL update statement")
@ManagedOperationParameters({
        @ManagedOperationParameter(name = "queryString", description = ""),
        @ManagedOperationParameter(name = "softDeletion", description = "")
})
String jpqlExecuteUpdate(String queryString, boolean softDeletion);
 
Example #15
Source File: Calculator.java    From Hands-On-High-Performance-with-Spring-5 with MIT License 5 votes vote down vote up
@ManagedOperation(description = "Calculate two numbers")
@ManagedOperationParameters({
		@ManagedOperationParameter(name = "x",
				description = "The first number"),
		@ManagedOperationParameter(name = "y",
				description = "The second number") })
public void calculate(int x, int y) {
	lastCalculation = x + y;
}
 
Example #16
Source File: ConfigStorageMBean.java    From cuba with Apache License 2.0 5 votes vote down vote up
@ManagedOperation(description = "Invoke a getter method of configuration interface and print the result")
@ManagedOperationParameters({
        @ManagedOperationParameter(name = "classFQN", description = "Fully qualified name of a configuration interface"),
        @ManagedOperationParameter(name = "methodName", description = "Getter method name"),
        @ManagedOperationParameter(name = "userLogin", description = "User login that will be used for creating a user session")
})
String getConfigValue(String classFQN, String methodName, String userLogin);
 
Example #17
Source File: ConfigStorageMBean.java    From cuba with Apache License 2.0 5 votes vote down vote up
@ManagedOperation(description = "Invoke a getter method of configuration interface and print the result")
@ManagedOperationParameters({
        @ManagedOperationParameter(name = "classFQN", description = "Fully qualified name of a configuration interface"),
        @ManagedOperationParameter(name = "methodName", description = "Getter method name"),
        @ManagedOperationParameter(name = "userLogin", description = "User login that will be used for creating a user session. " +
                "You can leave this field blank when using JMX console from CUBA application.")
})
String getConfigValue(String classFQN, String methodName, String userLogin);
 
Example #18
Source File: SchedulingMBean.java    From cuba with Apache License 2.0 4 votes vote down vote up
@ManagedOperation(description = "Removes executions occurred earlier than 'age' for tasks with period lesser than 'maxPeriod'")
@ManagedOperationParameters({
        @ManagedOperationParameter(name = "age", description = "Execution age in hours"),
        @ManagedOperationParameter(name = "maxPeriod", description = "Max task period in hours")})
String removeExecutionHistory(String age, String maxPeriod);
 
Example #19
Source File: AbstractServicesManagerMBean.java    From springboot-shiro-cas-mybatis with MIT License 4 votes vote down vote up
/**
 * Disable service.
 *
 * @param id the id
 */
@ManagedOperation(description = "Disable a service by id.")
@ManagedOperationParameter(name="id", description = "the identifier to disable")
public final void disableService(final long id) {
    changeEnabledState(id, false);
}
 
Example #20
Source File: AbstractServicesManagerMBean.java    From springboot-shiro-cas-mybatis with MIT License 4 votes vote down vote up
/**
 * Enable service.
 *
 * @param id the id
 */
@ManagedOperation(description = "Enable a service by its id.")
@ManagedOperationParameter(name="id", description = "the identifier to enable.")
public final void enableService(final long id) {
    changeEnabledState(id, true);
}
 
Example #21
Source File: AbstractServicesManagerMBean.java    From cas4.0.x-server-wechat with Apache License 2.0 4 votes vote down vote up
@ManagedOperation(description = "Can remove a service based on its identifier.")
@ManagedOperationParameter(name="id", description = "the identifier to remove")
public final RegisteredService removeService(final long id) {
    return this.servicesManager.delete(id);
}
 
Example #22
Source File: AbstractServicesManagerMBean.java    From cas4.0.x-server-wechat with Apache License 2.0 4 votes vote down vote up
@ManagedOperation(description = "Disable a service by id.")
@ManagedOperationParameter(name="id", description = "the identifier to disable")
public final void disableService(final long id) {
    changeEnabledState(id, false);
}
 
Example #23
Source File: AbstractServicesManagerMBean.java    From cas4.0.x-server-wechat with Apache License 2.0 4 votes vote down vote up
@ManagedOperation(description = "Enable a service by its id.")
@ManagedOperationParameter(name="id", description = "the identifier to enable.")
public final void enableService(final long id) {
    changeEnabledState(id, true);
}
 
Example #24
Source File: ConfigStorageMBean.java    From cuba with Apache License 2.0 4 votes vote down vote up
@ManagedOperation(description = "Print file-stored properties, filtering properties by beginning of name")
@ManagedOperationParameters({@ManagedOperationParameter(name = "prefix", description = "")})
String printAppProperties(String prefix);
 
Example #25
Source File: ConfigStorageMBean.java    From cuba with Apache License 2.0 4 votes vote down vote up
@ManagedOperation(description = "Print file-stored properties, filtering properties by beginning of name")
@ManagedOperationParameters({@ManagedOperationParameter(name = "prefix", description = "")})
String printAppProperties(String prefix);
 
Example #26
Source File: PositionManagerImpl.java    From FX-AlgorithmTrading with MIT License 4 votes vote down vote up
/**
 * 現在のポジションを編集します。
 * ポジションの変更にはダミーオーダーを使用します。
 *
 * @param symbolStr
 * @param netAmount
 * @param averagePrice
 * @return
 */
@ManagedOperation
@ManagedOperationParameters({
    @ManagedOperationParameter(name = "symbolStr", description = "Symbol.name()"),
    @ManagedOperationParameter(name = "netAmount", description = "Signed(+-) Net amount of the symbol"),
    @ManagedOperationParameter(name = "averagePrice", description = "Average price of the position")})
public String WARN_editPosition(String symbolStr, int netAmount, double averagePrice) {
    try {
        Symbol symbol = Symbol.valueOf(symbolStr);
        Position position = positionHolder.getPosition(symbol);
        if (position == null) {
            // ダミーのポジションを作成
            // amountはゼロで作成されるのでそのままでOK
            position = new Position(symbol);
        }

        // netAmountが変更後になるように差分のAmountを計算します
        int orderAmount = netAmount - position.getNetOpenAmount();
        Side side = null;
        if (orderAmount > 0 ) {
            side = Side.BUY;
        } else if (orderAmount < 0) {
            side = Side.SELL;
            orderAmount = Math.abs(orderAmount);
        } else {
            return "Error: New net amount and current net amount are the same.";
        }

        // averagePriceが変更後になるように差分のexecutePriceを計算します
        double executePrice = 0.0;
        if (NumberUtility.almostEquals(averagePrice, 0.0, 0.000001)) {
            // 指定がゼロの時は現在価格をexecutePriceとする。
            executePrice = marketDataMap.get(symbol).getMidPrice();
        } else {
            executePrice = Math.abs(netAmount * averagePrice - position.getNetOpenAmount() * position.getAveragePrice()) / orderAmount;
        }

        // ダミーオーダーを作成します。
        OrderBuilder orderBuilder = OrderBuilder.getBuilder()
                // 全般
                .setSymbol(symbol)
                .setMarketType(MarketType.DUMMY)
                .setOrderId(new Long(99999999))
                .setOrderAction(OrderAction.FILL)
                .setOrderStatus(OrderStatus.FILLED)
                .setModelType(ModelType.POSITION)
                .setModelVersion(ModelVersion.DUMMY_VERSION)
                // 詳細
                .setSide(side)
                .setOrderType(OrderType.MARKET)
                .setOrderPrice(0)
                .setOrderAmount(orderAmount)
                .setQuoteId(null)
                // 約定
                .setMarketPositionId(null)
                .setExecutePrice(executePrice)
                .setExecuteAmount(orderAmount)
                .setOriginalOrderId(null)
                .setOriginalMarketId(null)
                .setMarketDateTime(null);

        // Event作成
        OrderUpdateEvent orderUpdateEvent = new OrderUpdateEvent(uuid, getClass(), orderBuilder.createInstance());
        eventRouter.addEvent(orderUpdateEvent);

        return "Create dummy order : " + orderUpdateEvent.getContent().toStringSummary();
    } catch (Exception e) {
        return ExceptionUtility.getStackTraceString(e);
    }
}
 
Example #27
Source File: EmailerMBean.java    From cuba with Apache License 2.0 4 votes vote down vote up
@ManagedOperationParameters({@ManagedOperationParameter(name = "addresses", description = "")})
String sendTestEmail(String addresses);
 
Example #28
Source File: ScriptingManagerMBean.java    From cuba with Apache License 2.0 4 votes vote down vote up
@ManagedOperation(description = "Execute a Groovy script. Binding contains variables: persistence, metadata, configuration")
@ManagedOperationParameters(
        {@ManagedOperationParameter(name = "scriptName",
                description = "path to the script relative to conf dir or to the classpath root")})
String runGroovyScript(String scriptName);
 
Example #29
Source File: ConfigStorageMBean.java    From cuba with Apache License 2.0 4 votes vote down vote up
@ManagedOperation(description = "Print DB-stored properties, filtering properties by beginning of name")
@ManagedOperationParameters({@ManagedOperationParameter(name = "prefix", description = "")})
String printDbProperties(String prefix);
 
Example #30
Source File: UniqueNumbersMBean.java    From cuba with Apache License 2.0 4 votes vote down vote up
@ManagedOperationParameters({@ManagedOperationParameter(name = "domain", description = "")})
long getNextNumber(String domain);