Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
youfanx committed Dec 24, 2024
1 parent 670a414 commit bae784a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 14 deletions.
2 changes: 2 additions & 0 deletions rxlib-x/src/main/java/org/rx/jdbc/SimpleORM.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.rx.jdbc;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.rx.annotation.DbColumn;
Expand All @@ -25,6 +26,7 @@

@RequiredArgsConstructor
public class SimpleORM {
@Getter
final JdbcExecutor executor;

static final BiFunc<Class<?>, String> TO_UNDERSCORE_TABLE_MAPPING = t -> {
Expand Down
2 changes: 1 addition & 1 deletion rxlib/src/main/java/org/rx/core/Tasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public boolean isTerminated() {
}

@Override
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
public boolean awaitTermination(long timeout, TimeUnit unit) {
return shutdown;
}
};
Expand Down
22 changes: 13 additions & 9 deletions rxlib/src/main/java/org/rx/spring/MxController.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ public class MxController {
@SneakyThrows
@RequestMapping("health")
public Object health(HttpServletRequest request) {
final String rt = "1";
String multicast = request.getParameter("multicast");
if (multicast != null) {
String group = request.getParameter("group");
Integer mcId = Reflects.changeType(request.getParameter("mcId"), Integer.class);
NetEventWait.multicastLocal(Sockets.parseEndpoint(multicast), group, ifNull(mcId, 0));
return rt;
}

final HttpHeaders headers = new HttpHeaders();
// headers.setContentType(MediaType.valueOf("text/plain;charset=UTF-8"));
headers.setContentType(MediaType.TEXT_PLAIN);
Expand All @@ -74,7 +65,18 @@ public Object health(HttpServletRequest request) {
TraceHandler.INSTANCE.log("rx replay {}", buf);
return new ResponseEntity<>(buf, headers, HttpStatus.OK);
}

final String rt = "1";
ThreadPool.startTrace(null);
try {
String multicast = request.getParameter("multicast");
if (multicast != null) {
String group = request.getParameter("group");
Integer mcId = Reflects.changeType(request.getParameter("mcId"), Integer.class);
NetEventWait.multicastLocal(Sockets.parseEndpoint(multicast), group, ifNull(mcId, 0));
return rt;
}

switch (Integer.parseInt(x)) {
case 1:
Sys.diagnosticMx.setVMOption(request.getParameter("k"), request.getParameter("v"));
Expand Down Expand Up @@ -137,6 +139,8 @@ public Object health(HttpServletRequest request) {
return svrState(request);
} catch (Throwable e) {
return new ResponseEntity<>(String.format("%s\n%s", e, ExceptionUtils.getStackTrace(e)), headers, HttpStatus.OK);
} finally {
ThreadPool.endTrace();
}
}

Expand Down
41 changes: 37 additions & 4 deletions rxlib/src/main/java/org/rx/spring/SpringConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@

import org.rx.bean.Decimal;
import org.rx.core.Reflects;
import org.rx.core.Tasks;
import org.rx.net.AuthenticEndpoint;
import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.Primary;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.stereotype.Component;

import javax.validation.Validation;
import javax.validation.Validator;
import java.io.File;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;

@Configuration
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
Expand All @@ -29,10 +35,37 @@ public class SpringConfig
// return (e, m, a) -> TraceHandler.INSTANCE.log(e);
// }

// @Bean("defaultExecutorService")
// public ExecutorService executorService() {
// return Tasks.executor();
// }
@Primary
@Bean
public AsyncTaskExecutor asyncTaskExecutorEx() {
return new AsyncTaskExecutor() {
@Override
public void execute(Runnable task, long startTimeout) {
Tasks.executor().execute(task);
}

@Override
public Future<?> submit(Runnable task) {
return Tasks.executor().submit(task);
}

@Override
public <T> Future<T> submit(Callable<T> task) {
return Tasks.executor().submit(task);
}

@Override
public void execute(Runnable task) {
Tasks.executor().execute(task);
}
};
}

@Primary
@Bean
public ExecutorService executorServiceEx() {
return Tasks.executor();
}

@Bean
public Validator validator() {
Expand Down

0 comments on commit bae784a

Please sign in to comment.