use of org.apache.hc.core5.util.Args in project commons-vfs by apache.
the class NHttpFileServer method main.
public static void main(final String[] args) throws Exception {
if (args.length < 1) {
System.err.println("Please specify document root directory");
System.exit(1);
}
// Document root directory
final File docRoot = new File(args[0]);
int port = 8080;
if (args.length >= 2) {
port = Integer.parseInt(args[1]);
}
new NHttpFileServer(port, docRoot).start().awaitTermination();
}
use of org.apache.hc.core5.util.Args in project eomcs-java by eomcs.
the class Exam0110 method main.
public static void main(final String[] args) throws Exception {
final SocketConfig socketConfig = //
SocketConfig.custom().setSoTimeout(15, //
TimeUnit.SECONDS).setTcpNoDelay(//
true).build();
final HttpServer server = //
ServerBootstrap.bootstrap().setListenerPort(// 웹서버 포트 번호 설정
9999).setSocketConfig(// 기본 소켓 동작 설정
socketConfig).setSslContext(// SSL 설정
null).setExceptionListener(// 예외 처리자 설정
new MyExceptionListener()).register("*", // 요청 처리자 설정
new HttpFileHandler()).create();
// 웹서버를 시작시킨다.
server.start();
// 웹서버를 종료시키는 스레드를 등록한다.
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
server.close(CloseMode.GRACEFUL);
}
});
System.out.println("서버 시작(9999)!");
server.awaitTermination(TimeValue.MAX_VALUE);
}
use of org.apache.hc.core5.util.Args in project eomcs-java by eomcs.
the class Exam0210 method main.
public static void main(final String[] args) throws Exception {
final SocketConfig socketConfig = //
SocketConfig.custom().setSoTimeout(15, //
TimeUnit.SECONDS).setTcpNoDelay(//
true).build();
final HttpServer server = //
ServerBootstrap.bootstrap().setListenerPort(// 웹서버 포트 번호 설정
9999).setSocketConfig(// 기본 소켓 동작 설정
socketConfig).setSslContext(// SSL 설정
null).setExceptionListener(// 예외 처리자 설정
new MyExceptionListener()).register("*", // 요청 처리자 설정
new MyRequestHandler()).create();
// 웹서버를 시작시킨다.
server.start();
// 웹서버를 종료시키는 스레드를 등록한다.
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
server.close(CloseMode.GRACEFUL);
}
});
System.out.println("서버 시작(9999)!");
server.awaitTermination(TimeValue.MAX_VALUE);
}
use of org.apache.hc.core5.util.Args in project easeagent by megaease.
the class HttpClient5DoExecuteInterceptorTest method before.
@Test
public void before() {
Context context = EaseAgent.getContext();
HttpGet httpGet = new HttpGet("http://127.0.0.1:8080");
BasicHttpResponse basicHttpResponse = new BasicHttpResponse(200);
basicHttpResponse.setHeader(TestConst.RESPONSE_TAG_NAME, TestConst.RESPONSE_TAG_VALUE);
MethodInfo methodInfo = MethodInfo.builder().args(new Object[] { httpGet }).retValue(basicHttpResponse).build();
HttpClient5DoExecuteInterceptor httpClient5DoExecuteInterceptor = new HttpClient5DoExecuteInterceptor();
MockEaseAgent.cleanLastSpan();
httpClient5DoExecuteInterceptor.before(methodInfo, context);
httpClient5DoExecuteInterceptor.after(methodInfo, context);
ReportSpan mockSpan = MockEaseAgent.getLastSpan();
assertNotNull(mockSpan);
assertEquals(Span.Kind.CLIENT.name(), mockSpan.kind());
assertEquals(TestConst.RESPONSE_TAG_VALUE, mockSpan.tag(TestConst.RESPONSE_TAG_NAME));
assertNull(mockSpan.parentId());
Span span = context.nextSpan();
try (Scope ignored = span.maybeScope()) {
httpClient5DoExecuteInterceptor.doBefore(methodInfo, context);
httpClient5DoExecuteInterceptor.doAfter(methodInfo, context);
mockSpan = MockEaseAgent.getLastSpan();
assertEquals(span.traceIdString(), mockSpan.traceId());
assertEquals(span.spanIdString(), mockSpan.parentId());
assertNotNull(mockSpan.id());
}
}
use of org.apache.hc.core5.util.Args in project LinkAgent by shulieTech.
the class HttpClientv5MethodInterceptor method exceptionTrace.
@Override
public SpanRecord exceptionTrace(Advice advice) {
Object[] args = advice.getParameterArray();
HttpRequest request = (HttpRequest) args[1];
SpanRecord record = new SpanRecord();
if (advice.getThrowable() instanceof SocketTimeoutException) {
record.setResultCode(ResultCode.INVOKE_RESULT_TIMEOUT);
} else {
record.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
}
try {
record.setRequest(getParameters(request));
} catch (Throwable e) {
}
record.setResponse(advice.getThrowable());
return record;
}
Aggregations