forked from wenweihu86/raft-java
-
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.
add symbolic link support for snapshot
- Loading branch information
1 parent
5838c4f
commit 8867e76
Showing
11 changed files
with
70 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
java -cp dependency/*:raft-java-admin-1.3.0.jar com.github.wenweihu86.raft.admin.AdminMain "127.0.0.1:8051,127.0.0.1:8052,127.0.0.1:8053" conf get | ||
java -cp dependency/*:raft-java-admin-1.4.0.jar com.github.wenweihu86.raft.admin.AdminMain "127.0.0.1:8051,127.0.0.1:8052,127.0.0.1:8053" conf get | ||
|
||
java -cp dependency/*:raft-java-admin-1.3.0.jar com.github.wenweihu86.raft.admin.AdminMain "127.0.0.1:8051,127.0.0.1:8052,127.0.0.1:8053" conf add "127.0.0.1:8054:4,127.0.0.1:8055:5" | ||
java -cp dependency/*:raft-java-admin-1.4.0.jar com.github.wenweihu86.raft.admin.AdminMain "127.0.0.1:8051,127.0.0.1:8052,127.0.0.1:8053" conf add "127.0.0.1:8054:4,127.0.0.1:8055:5" | ||
|
||
java -cp dependency/*:raft-java-admin-1.3.0.jar com.github.wenweihu86.raft.admin.AdminMain "127.0.0.1:8051,127.0.0.1:8052,127.0.0.1:8053" conf del "127.0.0.1:8054:4,127.0.0.1:8055:5" | ||
java -cp dependency/*:raft-java-admin-1.4.0.jar com.github.wenweihu86.raft.admin.AdminMain "127.0.0.1:8051,127.0.0.1:8052,127.0.0.1:8053" conf del "127.0.0.1:8054:4,127.0.0.1:8055:5" |
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
41 changes: 41 additions & 0 deletions
41
raft-java-core/src/test/java/com/github/wenweihu86/raft/storage/SnapshotTest.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,41 @@ | ||
package com.github.wenweihu86.raft.storage; | ||
|
||
import com.github.wenweihu86.raft.RaftOptions; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.FileSystems; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.TreeMap; | ||
|
||
/** | ||
* Created by wenweihu86 on 2017/7/2. | ||
*/ | ||
public class SnapshotTest { | ||
|
||
@Test | ||
public void testReadSnapshotDataFiles() throws IOException { | ||
RaftOptions.dataDir = "./data"; | ||
File file = new File("./data/message"); | ||
file.mkdirs(); | ||
File file1 = new File("./data/message/queue1.txt"); | ||
file1.createNewFile(); | ||
File file2 = new File("./data/message/queue2.txt"); | ||
file2.createNewFile(); | ||
|
||
File snapshotFile = new File("./data/snapshot"); | ||
snapshotFile.mkdirs(); | ||
Path link = FileSystems.getDefault().getPath("./data/snapshot/data"); | ||
Path target = FileSystems.getDefault().getPath("./data/message").toRealPath(); | ||
Files.createSymbolicLink(link, target); | ||
|
||
Snapshot snapshot = new Snapshot(); | ||
TreeMap<String, Snapshot.SnapshotDataFile> snapshotFileMap = snapshot.readSnapshotDataFiles(); | ||
System.out.println(snapshotFileMap.keySet()); | ||
Assert.assertTrue(snapshotFileMap.size() == 2); | ||
Assert.assertTrue(snapshotFileMap.firstKey().equals("queue1.txt")); | ||
} | ||
} |
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,5 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
java -cp dependency/*:raft-java-example-1.3.0.jar com.github.wenweihu86.raft.example.client.ClientMain "127.0.0.1:8051,127.0.0.1:8052,127.0.0.1:8053" hello raft | ||
java -cp dependency/*:raft-java-example-1.4.0.jar com.github.wenweihu86.raft.example.client.ClientMain "127.0.0.1:8051,127.0.0.1:8052,127.0.0.1:8053" hello raft | ||
|
||
java -cp dependency/*:raft-java-example-1.3.0.jar com.github.wenweihu86.raft.example.client.ConcurrentClientMain "127.0.0.1:8051,127.0.0.1:8052,127.0.0.1:8053" | ||
java -cp dependency/*:raft-java-example-1.4.0.jar com.github.wenweihu86.raft.example.client.ConcurrentClientMain "127.0.0.1:8051,127.0.0.1:8052,127.0.0.1:8053" |
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,11 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
java -Dcom.github.wenweihu86.raft.data.dir=/Users/baidu/local/raft-java-example1/data -cp dependency/*:raft-java-example-1.3.0.jar com.github.wenweihu86.raft.example.server.ServerMain "127.0.0.1:8051:1,127.0.0.1:8052:2,127.0.0.1:8053:3" "127.0.0.1:8051:1" | ||
java -Dcom.github.wenweihu86.raft.data.dir=/Users/baidu/local/raft-java-example1/data -cp dependency/*:raft-java-example-1.4.0.jar com.github.wenweihu86.raft.example.server.ServerMain "127.0.0.1:8051:1,127.0.0.1:8052:2,127.0.0.1:8053:3" "127.0.0.1:8051:1" | ||
|
||
java -Dcom.github.wenweihu86.raft.data.dir=/Users/baidu/local/raft-java-example2/data -cp dependency/*:raft-java-example-1.3.0.jar com.github.wenweihu86.raft.example.server.ServerMain "127.0.0.1:8051:1,127.0.0.1:8052:2,127.0.0.1:8053:3" "127.0.0.1:8052:2" | ||
java -Dcom.github.wenweihu86.raft.data.dir=/Users/baidu/local/raft-java-example2/data -cp dependency/*:raft-java-example-1.4.0.jar com.github.wenweihu86.raft.example.server.ServerMain "127.0.0.1:8051:1,127.0.0.1:8052:2,127.0.0.1:8053:3" "127.0.0.1:8052:2" | ||
|
||
java -Dcom.github.wenweihu86.raft.data.dir=/Users/baidu/local/raft-java-example3/data -cp dependency/*:raft-java-example-1.3.0.jar com.github.wenweihu86.raft.example.server.ServerMain "127.0.0.1:8051:1,127.0.0.1:8052:2,127.0.0.1:8053:3" "127.0.0.1:8053:3" | ||
java -Dcom.github.wenweihu86.raft.data.dir=/Users/baidu/local/raft-java-example3/data -cp dependency/*:raft-java-example-1.4.0.jar com.github.wenweihu86.raft.example.server.ServerMain "127.0.0.1:8051:1,127.0.0.1:8052:2,127.0.0.1:8053:3" "127.0.0.1:8053:3" | ||
|
||
java -Dcom.github.wenweihu86.raft.data.dir=/Users/baidu/local/raft-java-example4/data -cp dependency/*:raft-java-example-1.3.0.jar com.github.wenweihu86.raft.example.server.ServerMain "127.0.0.1:8051:1,127.0.0.1:8052:2,127.0.0.1:8053:3" "127.0.0.1:8054:4" | ||
java -Dcom.github.wenweihu86.raft.data.dir=/Users/baidu/local/raft-java-example4/data -cp dependency/*:raft-java-example-1.4.0.jar com.github.wenweihu86.raft.example.server.ServerMain "127.0.0.1:8051:1,127.0.0.1:8052:2,127.0.0.1:8053:3" "127.0.0.1:8054:4" | ||
|
||
java -Dcom.github.wenweihu86.raft.data.dir=/Users/baidu/local/raft-java-example5/data -cp dependency/*:raft-java-example-1.3.0.jar com.github.wenweihu86.raft.example.server.ServerMain "127.0.0.1:8051:1,127.0.0.1:8052:2,127.0.0.1:8053:3" "127.0.0.1:8055:5" | ||
java -Dcom.github.wenweihu86.raft.data.dir=/Users/baidu/local/raft-java-example5/data -cp dependency/*:raft-java-example-1.4.0.jar com.github.wenweihu86.raft.example.server.ServerMain "127.0.0.1:8051:1,127.0.0.1:8052:2,127.0.0.1:8053:3" "127.0.0.1:8055:5" |