-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
222 additions
and
81 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<hosts> | ||
<host> | ||
<ip>192.168.1.22</ip> | ||
</host> | ||
<clusterSize> | ||
5 | ||
</clusterSize> | ||
<leaderPort> | ||
<port>30303</port> | ||
</leaderPort> | ||
<persistencyPath> | ||
|
||
</persistencyPath> | ||
</hosts> | ||
<host> | ||
<ip>127.0.0.1:50000</ip> | ||
</host> |
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,45 @@ | ||
package KV.Client; | ||
|
||
import org.dom4j.Document; | ||
import org.dom4j.Element; | ||
import org.dom4j.io.SAXReader; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
|
||
/** | ||
* Created by jrj on 18-2-6. | ||
*/ | ||
public class ClientConfig { | ||
ArrayList<String> ipPortList = new ArrayList<String>(); | ||
ClientConfig(String filePath) throws Exception{ | ||
SAXReader reader = new SAXReader(); | ||
Document document = reader.read(new File(filePath)); | ||
Element root = document.getRootElement(); | ||
initMap(root); | ||
} | ||
|
||
private void initMap(Element node){ | ||
Element element = node.element("host"); | ||
Iterator<Element> iterator = element.elementIterator(); | ||
while(iterator.hasNext()){ | ||
Element elementInside = iterator.next(); | ||
ipPortList.add(elementInside.getText()); | ||
} | ||
} | ||
|
||
public ArrayList<String> getIpPortList(){ | ||
return ipPortList; | ||
} | ||
|
||
public static void main(String[] args){ | ||
try { | ||
ClientConfig clientConfig = new ClientConfig("/home/jrj/Desktop/idea-IU-163.12024.16/java_learn/EasyRaft/src/main/java/KV/Client/config.xml"); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<hosts> | ||
<host> | ||
<ip>127.0.0.1:50000</ip> | ||
<ip>127.0.0.1:50001</ip> | ||
<ip>127.0.0.1:50002</ip> | ||
</host> | ||
</hosts> |
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
Oops, something went wrong.