You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ra...@apache.org on 2017/11/14 04:09:40 UTC
olingo-odata4 git commit: [OLINGO-1201] Enhancements to run better
with Netty
Repository: olingo-odata4
Updated Branches:
refs/heads/master 1ce51fd4e -> 5e21bb2ba
[OLINGO-1201] Enhancements to run better with Netty
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/5e21bb2b
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/5e21bb2b
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/5e21bb2b
Branch: refs/heads/master
Commit: 5e21bb2ba5d677893b6f87fcd04e2fcd7034654e
Parents: 1ce51fd
Author: ramya vasanth <ra...@sap.com>
Authored: Tue Nov 14 09:39:31 2017 +0530
Committer: ramya vasanth <ra...@sap.com>
Committed: Tue Nov 14 09:39:31 2017 +0530
----------------------------------------------------------------------
lib/server-api/pom.xml | 5 +
.../olingo/server/api/ODataHttpHandler.java | 2 +-
lib/server-core/pom.xml | 5 +
.../server/core/ODataHttpHandlerImpl.java | 101 ++++++++++---------
.../server/core/debug/ServerCoreDebugger.java | 2 +-
5 files changed, 64 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5e21bb2b/lib/server-api/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-api/pom.xml b/lib/server-api/pom.xml
index 6d3987e..f651116 100644
--- a/lib/server-api/pom.xml
+++ b/lib/server-api/pom.xml
@@ -50,6 +50,11 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ <version>4.1.16.Final</version>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5e21bb2b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java
index 4c18e2e..61e0f0f 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java
@@ -39,7 +39,7 @@ public interface ODataHttpHandler extends ODataHandler {
* @param response - HTTP OData response
*/
void process(HttpServletRequest request, HttpServletResponse response);
-
+
/**
* Sets the split parameter which is used for service resolution.
* @param split the number of path segments reserved for service resolution; default is 0
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5e21bb2b/lib/server-core/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-core/pom.xml b/lib/server-core/pom.xml
index 7f88e08..2e7ed61 100644
--- a/lib/server-core/pom.xml
+++ b/lib/server-core/pom.xml
@@ -79,6 +79,11 @@
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ <version>4.1.16.Final</version>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5e21bb2b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
index 6c4b1b3..bbd94e5 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
@@ -125,7 +125,7 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
environment.put("servletPath", request.getServletPath());
return environment;
}
-
+
private String getIntAsString(final int number) {
return number == 0 ? "unknown" : Integer.toString(number);
}
@@ -164,7 +164,7 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
writeContent(odResponse, response);
}
}
-
+
static void writeContent(final ODataResponse odataResponse, final HttpServletResponse servletResponse) {
try {
ODataContent res = odataResponse.getODataContent();
@@ -195,7 +195,7 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
closeStream(output);
}
}
-
+
private static void closeStream(final Channel closeable) {
if (closeable != null) {
try {
@@ -205,7 +205,7 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
}
}
}
-
+
private ODataRequest fillODataRequest(final ODataRequest odRequest, final HttpServletRequest httpRequest,
final int split) throws ODataLibraryException {
final int requestHandle = debugger.startRuntimeMeasurement("ODataHttpHandlerImpl", "fillODataRequest");
@@ -228,43 +228,44 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
debugger.stopRuntimeMeasurement(requestHandle);
}
}
-
+
static HttpMethod extractMethod(final HttpServletRequest httpRequest) throws ODataLibraryException {
- final HttpMethod httpRequestMethod;
- try {
- httpRequestMethod = HttpMethod.valueOf(httpRequest.getMethod());
- } catch (IllegalArgumentException e) {
- throw new ODataHandlerException("HTTP method not allowed" + httpRequest.getMethod(), e,
- ODataHandlerException.MessageKeys.HTTP_METHOD_NOT_ALLOWED, httpRequest.getMethod());
- }
- try {
- if (httpRequestMethod == HttpMethod.POST) {
- String xHttpMethod = httpRequest.getHeader(HttpHeader.X_HTTP_METHOD);
- String xHttpMethodOverride = httpRequest.getHeader(HttpHeader.X_HTTP_METHOD_OVERRIDE);
-
- if (xHttpMethod == null && xHttpMethodOverride == null) {
- return httpRequestMethod;
- } else if (xHttpMethod == null) {
- return HttpMethod.valueOf(xHttpMethodOverride);
- } else if (xHttpMethodOverride == null) {
- return HttpMethod.valueOf(xHttpMethod);
- } else {
- if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {
- throw new ODataHandlerException("Ambiguous X-HTTP-Methods",
- ODataHandlerException.MessageKeys.AMBIGUOUS_XHTTP_METHOD, xHttpMethod, xHttpMethodOverride);
- }
- return HttpMethod.valueOf(xHttpMethod);
- }
- } else {
- return httpRequestMethod;
- }
- } catch (IllegalArgumentException e) {
- throw new ODataHandlerException("Invalid HTTP method" + httpRequest.getMethod(), e,
- ODataHandlerException.MessageKeys.INVALID_HTTP_METHOD, httpRequest.getMethod());
- }
- }
-
- static void fillUriInformation(final ODataRequest odRequest, final HttpServletRequest httpRequest, final int split) {
+ final HttpMethod httpRequestMethod;
+ try {
+ httpRequestMethod = HttpMethod.valueOf(httpRequest.getMethod());
+ } catch (IllegalArgumentException e) {
+ throw new ODataHandlerException("HTTP method not allowed" + httpRequest.getMethod(), e,
+ ODataHandlerException.MessageKeys.HTTP_METHOD_NOT_ALLOWED, httpRequest.getMethod());
+ }
+ try {
+ if (httpRequestMethod == HttpMethod.POST) {
+ String xHttpMethod = httpRequest.getHeader(HttpHeader.X_HTTP_METHOD);
+ String xHttpMethodOverride = httpRequest.getHeader(HttpHeader.X_HTTP_METHOD_OVERRIDE);
+
+ if (xHttpMethod == null && xHttpMethodOverride == null) {
+ return httpRequestMethod;
+ } else if (xHttpMethod == null) {
+ return HttpMethod.valueOf(xHttpMethodOverride);
+ } else if (xHttpMethodOverride == null) {
+ return HttpMethod.valueOf(xHttpMethod);
+ } else {
+ if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {
+ throw new ODataHandlerException("Ambiguous X-HTTP-Methods",
+ ODataHandlerException.MessageKeys.AMBIGUOUS_XHTTP_METHOD, xHttpMethod, xHttpMethodOverride);
+ }
+ return HttpMethod.valueOf(xHttpMethod);
+ }
+ } else {
+ return httpRequestMethod;
+ }
+ } catch (IllegalArgumentException e) {
+ throw new ODataHandlerException("Invalid HTTP method" + httpRequest.getMethod(), e,
+ ODataHandlerException.MessageKeys.INVALID_HTTP_METHOD, httpRequest.getMethod());
+ }
+ }
+
+ static void fillUriInformation(final ODataRequest odRequest,
+ final HttpServletRequest httpRequest, final int split) {
String rawRequestUri = httpRequest.getRequestURL().toString();
String rawODataPath;
@@ -274,10 +275,12 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
int beginIndex = rawRequestUri.indexOf(requestMapping) + requestMapping.length();
rawODataPath = rawRequestUri.substring(beginIndex);
}else if(!"".equals(httpRequest.getServletPath())) {
- int beginIndex = rawRequestUri.indexOf(httpRequest.getServletPath()) + httpRequest.getServletPath().length();
+ int beginIndex = rawRequestUri.indexOf(httpRequest.getServletPath()) +
+ httpRequest.getServletPath().length();
rawODataPath = rawRequestUri.substring(beginIndex);
} else if (!"".equals(httpRequest.getContextPath())) {
- int beginIndex = rawRequestUri.indexOf(httpRequest.getContextPath()) + httpRequest.getContextPath().length();
+ int beginIndex = rawRequestUri.indexOf(httpRequest.getContextPath()) +
+ httpRequest.getContextPath().length();
rawODataPath = rawRequestUri.substring(beginIndex);
} else {
rawODataPath = httpRequest.getRequestURI();
@@ -310,13 +313,13 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
}
static void copyHeaders(ODataRequest odRequest, final HttpServletRequest req) {
- for (final Enumeration<?> headerNames = req.getHeaderNames(); headerNames.hasMoreElements();) {
- final String headerName = (String) headerNames.nextElement();
- @SuppressWarnings("unchecked")
- // getHeaders() says it returns an Enumeration of String.
- final List<String> headerValues = Collections.list(req.getHeaders(headerName));
- odRequest.addHeader(headerName, headerValues);
- }
+ for (final Enumeration<?> headerNames = req.getHeaderNames(); headerNames.hasMoreElements();) {
+ final String headerName = (String) headerNames.nextElement();
+ @SuppressWarnings("unchecked")
+ // getHeaders() says it returns an Enumeration of String.
+ final List<String> headerValues = Collections.list(req.getHeaders(headerName));
+ odRequest.addHeader(headerName, headerValues);
+ }
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5e21bb2b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ServerCoreDebugger.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ServerCoreDebugger.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ServerCoreDebugger.java
index cf80073..1fd85b7 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ServerCoreDebugger.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ServerCoreDebugger.java
@@ -62,7 +62,7 @@ public class ServerCoreDebugger {
}
}
}
-
+
public ODataResponse createDebugResponse(final ODataRequest request, final ODataResponse response,
final Exception exception, final UriInfo uriInfo, final Map<String, String> serverEnvironmentVariables) {
// Failsafe so we do not generate unauthorized debug messages