-
Notifications
You must be signed in to change notification settings - Fork 520
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
feat(server): enhance transaction in graph server #2686
Open
Aph-CUG
wants to merge
10
commits into
apache:master
Choose a base branch
from
Aph-CUG:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+454
−14
Open
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ce21105
tx enhancer
cce27d4
Merge pull request #1 from Aph-CUG/dev-aph
Aph-CUG 0c79c2c
事务性增强
Aph-CUG 833a326
Merge branch 'master' into master
Aph-CUG e19bf22
update
1a8e0d9
Merge pull request #2 from Aph-CUG/dev-aph
Aph-CUG 3062fa3
update
741db7e
Merge remote-tracking branch 'origin/dev-aph' into dev-aph
2015e14
Merge branch 'master' into dev-aph
Aph-CUG 511e59d
Merge pull request #3 from Aph-CUG/dev-aph
Aph-CUG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/variables/CheckList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package org.apache.hugegraph.variables; | ||
|
||
import org.apache.hugegraph.config.HugeConfig; | ||
import org.apache.hugegraph.masterelection.GlobalMasterInfo; | ||
|
||
import java.io.Serializable; | ||
|
||
public class CheckList implements Serializable { | ||
|
||
private String name; | ||
private String configText; | ||
|
||
private HugeConfig config; | ||
|
||
private boolean initBackended; | ||
|
||
private boolean serverStarted; | ||
|
||
private String stage; | ||
|
||
private String configPath; | ||
|
||
private GlobalMasterInfo nodeInfo; | ||
|
||
boolean toCheck; | ||
String context; | ||
private boolean isBuild; | ||
|
||
public void setBuild(boolean build) { | ||
isBuild = build; | ||
} | ||
|
||
public CheckList(String name, String context) { | ||
this.name = name; | ||
this.context = context; | ||
} | ||
|
||
public HugeConfig getConfig() { | ||
return config; | ||
} | ||
|
||
public void setConfig(HugeConfig config) { | ||
this.config = config; | ||
} | ||
|
||
public boolean isInitBackended() { | ||
return initBackended; | ||
} | ||
|
||
public void setInitBackended(boolean initBackended) { | ||
this.initBackended = initBackended; | ||
} | ||
|
||
public boolean isServerStarted() { | ||
return serverStarted; | ||
} | ||
|
||
public void setServerStarted(boolean serverStarted) { | ||
this.serverStarted = serverStarted; | ||
} | ||
|
||
public String getStage() { | ||
return stage; | ||
} | ||
|
||
public void setStage(String stage) { | ||
this.stage = stage; | ||
} | ||
|
||
public String getConfigPath() { | ||
return configPath; | ||
} | ||
|
||
public void setConfigPath(String configPath) { | ||
this.configPath = configPath; | ||
} | ||
|
||
public GlobalMasterInfo getNodeInfo() { | ||
return nodeInfo; | ||
} | ||
|
||
public void setNodeInfo(GlobalMasterInfo nodeInfo) { | ||
this.nodeInfo = nodeInfo; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/TxScanner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package org.apache.hugegraph; | ||
|
||
import org.apache.hugegraph.config.HugeConfig; | ||
import org.apache.hugegraph.core.GraphManager; | ||
import org.apache.hugegraph.masterelection.GlobalMasterInfo; | ||
import org.apache.hugegraph.pd.client.KvClient; | ||
import org.apache.hugegraph.pd.common.PDException; | ||
import org.apache.hugegraph.pd.grpc.kv.ScanPrefixResponse; | ||
import org.apache.hugegraph.pd.grpc.kv.WatchResponse; | ||
import org.apache.hugegraph.util.ConfigUtil; | ||
import org.apache.hugegraph.util.Events; | ||
import org.apache.hugegraph.util.JsonUtil; | ||
import org.apache.hugegraph.variables.CheckList; | ||
import org.apache.tinkerpop.gremlin.structure.util.GraphFactory; | ||
|
||
|
||
|
||
public class TxScanner { | ||
private final String prefix = "graph_creat_tx"; | ||
|
||
private KvClient<WatchResponse> client; | ||
|
||
public TxScanner(KvClient<WatchResponse> client) { | ||
} | ||
|
||
|
||
public void scan() { | ||
try { | ||
ScanPrefixResponse response = this.client.scanPrefix(prefix); | ||
for(String key : response.getKvsMap().keySet()) { | ||
String value = response.getKvsMap().get(key); | ||
CheckList checkList = JsonUtil.fromJson(value, CheckList.class); | ||
switch (checkList.getStage()) { | ||
case "config": { | ||
configContinue(checkList); | ||
} | ||
case "initBackend" : { | ||
HugeConfig config = checkList.getConfig(); | ||
HugeGraph graph = (HugeGraph) GraphFactory.open(config); | ||
GlobalMasterInfo globalMasterInfo = checkList.getNodeInfo(); | ||
graph.serverStarted(globalMasterInfo); | ||
// Write config to disk file | ||
String confPath = ConfigUtil.writeToFile(checkList.getConfigPath(), graph.name(), | ||
(HugeConfig)graph.configuration()); | ||
} | ||
case "setServerStarted" : { | ||
HugeConfig config = checkList.getConfig(); | ||
HugeGraph graph = (HugeGraph) GraphFactory.open(config); | ||
String confPath = ConfigUtil.writeToFile(checkList.getConfigPath(), graph.name(), | ||
(HugeConfig)graph.configuration()); | ||
} | ||
case "finish" : { | ||
client.delete(prefix + checkList.getName()); | ||
} | ||
} | ||
} | ||
} catch (PDException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
} | ||
|
||
private void configContinue(CheckList checkList) { | ||
HugeConfig config = checkList.getConfig(); | ||
HugeGraph graph = (HugeGraph) GraphFactory.open(config); | ||
try { | ||
// Create graph instance | ||
graph = (HugeGraph) GraphFactory.open(config); | ||
String configPath = checkList.getConfigPath(); | ||
GlobalMasterInfo globalMasterInfo = checkList.getNodeInfo(); | ||
// Init graph and start it | ||
graph.create(configPath, globalMasterInfo); | ||
} catch (Throwable e) { | ||
throw e; | ||
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. don't need to catch if we just re-throw here? |
||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can we add some comments that we don't expect break here and explain why