-
Notifications
You must be signed in to change notification settings - Fork 97
BREAKING CHANGE(hubble): upgrade to new version 2.0 [WIP] #632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
e638ba6
cac690d
2b46abf
96e7f70
5e9e16a
9e1c872
7ce5b0c
35290c6
46231e3
e27f64b
99160e9
6760f2c
acd6948
b7f63de
7b74852
0362086
5a50a92
3a4818d
ba7423e
d3a3afb
5c79ea4
deadd30
10e95a9
450fb2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,28 +27,34 @@ | |
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
|
||
import java.time.ZoneOffset; | ||
import java.util.TimeZone; | ||
|
||
@SpringBootApplication | ||
@EnableScheduling | ||
@MapperScan("org.apache.hugegraph.mapper") | ||
public class HugeGraphHubble extends SpringBootServletInitializer { | ||
|
||
public static void main(String[] args) { | ||
System.out.println("user.dir ==> " + System.getProperty("user.dir")); | ||
initEnv(); | ||
TimeZone.setDefault(TimeZone.getTimeZone(ZoneOffset.of("+8"))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the zone default +8 should set by config, because the repo not only use in china There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some. infra cant auto transform zone, so maybe wo shouldn't set default zone |
||
SpringApplication.run(HugeGraphHubble.class, args); | ||
} | ||
|
||
public static void initEnv() { | ||
String hubbleHomePath = System.getProperty("hubble.home.path"); | ||
Ex.check(StringUtils.isNotEmpty(hubbleHomePath), | ||
"The system property 'hubble.home.path' must be set"); | ||
"The system property 'hubble.home.path' must be set"); | ||
String loaderHomePath = System.getProperty("loader.home.path"); | ||
if (StringUtils.isEmpty(loaderHomePath)) { | ||
System.setProperty("loader.home.path", hubbleHomePath); | ||
} | ||
} | ||
|
||
@Override | ||
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { | ||
protected SpringApplicationBuilder configure( | ||
SpringApplicationBuilder builder) { | ||
return builder.sources(this.getClass()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* | ||
* 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.hugegraph.common; | ||
|
||
|
||
import org.apache.hugegraph.type.define.SerialEnum; | ||
|
||
public enum AppName implements SerialEnum { | ||
GREMLIN(1, "GREMLIN"), | ||
|
||
VERTEX_UPDATE(2, "VERTEX_UPDATE"), | ||
|
||
EDGE_UPDATE(3, "EDGE_UPDATE") | ||
; | ||
|
||
private final byte code; | ||
private final String name; | ||
|
||
static { | ||
SerialEnum.register(AppName.class); | ||
} | ||
|
||
AppName(int code, String name) { | ||
assert code < 256; | ||
this.code = (byte) code; | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public byte code() { | ||
return this.code; | ||
} | ||
|
||
public String string() { | ||
return this.name; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* | ||
* 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.hugegraph.common; | ||
|
||
|
||
import org.apache.hugegraph.type.define.SerialEnum; | ||
|
||
public enum AppType implements SerialEnum { | ||
// 通用功能 | ||
GENERAL(1, "GENERAL"), | ||
|
||
// 定制功能 | ||
CUSTOMIZED(2, "CUSTOMIZED"), | ||
|
||
; | ||
|
||
private final byte code; | ||
private final String name; | ||
|
||
static { | ||
SerialEnum.register(AppName.class); | ||
} | ||
|
||
AppType(int code, String name) { | ||
assert code < 256; | ||
this.code = (byte) code; | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public byte code() { | ||
return this.code; | ||
} | ||
|
||
public String string() { | ||
return this.name; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,4 @@ | |
package org.apache.hugegraph.common; | ||
|
||
public interface Mergeable { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* | ||
* 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.hugegraph.common; | ||
|
||
|
||
import org.apache.hugegraph.type.define.SerialEnum; | ||
|
||
public enum OptionType implements SerialEnum { | ||
|
||
|
||
DELETE(1, "DELETE"), | ||
|
||
ADD(2, "ADD"), | ||
|
||
UPDATE(3, "UPDATE"), | ||
|
||
; | ||
|
||
private final byte code; | ||
private final String name; | ||
|
||
static { | ||
SerialEnum.register(OptionType.class); | ||
} | ||
|
||
OptionType(int code, String name) { | ||
assert code < 256; | ||
this.code = (byte) code; | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public byte code() { | ||
return this.code; | ||
} | ||
|
||
public String string() { | ||
return this.name; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* | ||
* 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.hugegraph.config; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.http.HttpRequest; | ||
import org.apache.http.HttpResponse; | ||
import org.apache.http.HttpVersion; | ||
import org.apache.http.entity.StringEntity; | ||
import org.apache.http.message.BasicHttpResponse; | ||
import org.apache.hugegraph.common.Constant; | ||
import org.mitre.dsmiley.httpproxy.ProxyServlet; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
|
||
public class IngestionProxyServlet extends ProxyServlet { | ||
@Override | ||
protected String rewriteQueryStringFromRequest( | ||
HttpServletRequest servletRequest, String queryString) { | ||
String username = | ||
(String) servletRequest.getSession().getAttribute("username"); | ||
|
||
String requestQueryString = servletRequest.getQueryString(); | ||
|
||
if (StringUtils.isEmpty(requestQueryString)) { | ||
requestQueryString = String.format("user=%s", username); | ||
} else { | ||
requestQueryString += String.format("&user=%s", username); | ||
} | ||
|
||
return requestQueryString; | ||
} | ||
|
||
@Override | ||
protected HttpResponse doExecute(HttpServletRequest servletRequest, | ||
HttpServletResponse servletResponse, | ||
HttpRequest proxyRequest) throws IOException { | ||
String username = | ||
(String) servletRequest.getSession().getAttribute("username"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. magic |
||
|
||
if (username == null) { | ||
// check user login | ||
HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, | ||
Constant.STATUS_OK, | ||
"{\"status\": 401}"); | ||
|
||
response.setEntity(new StringEntity("{\"status\": 401}")); | ||
|
||
return response; | ||
} | ||
|
||
return super.doExecute(servletRequest, servletResponse, proxyRequest); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log replace system.out