Skip to content

Commit 6b3992b

Browse files
committed
RAFT: leader election start
1 parent b9cdf2c commit 6b3992b

16 files changed

Lines changed: 1006 additions & 0 deletions

File tree

hazelcast-raft/pom.xml

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
<!--
2+
~ Copyright (c) 2008-2017, Hazelcast, Inc. All Rights Reserved.
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
19+
<modelVersion>4.0.0</modelVersion>
20+
21+
<name>hazelcast raft</name>
22+
<artifactId>hazelcast-raft</artifactId>
23+
<description>Hazelcast Raft Module</description>
24+
<packaging>jar</packaging>
25+
26+
<parent>
27+
<groupId>com.hazelcast</groupId>
28+
<artifactId>hazelcast-root</artifactId>
29+
<version>3.10-SNAPSHOT</version>
30+
<relativePath>../pom.xml</relativePath>
31+
</parent>
32+
33+
<properties>
34+
<!-- needed for checkstyle/findbugs -->
35+
<main.basedir>${project.parent.basedir}</main.basedir>
36+
</properties>
37+
38+
<build>
39+
<plugins>
40+
<plugin>
41+
<groupId>pl.project13.maven</groupId>
42+
<artifactId>git-commit-id-plugin</artifactId>
43+
<version>${maven.git.commit.id.plugin.version}</version>
44+
<executions>
45+
<execution>
46+
<goals>
47+
<goal>revision</goal>
48+
</goals>
49+
</execution>
50+
</executions>
51+
<configuration>
52+
<useNativeGit>false</useNativeGit>
53+
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
54+
<failOnNoGitDirectory>false</failOnNoGitDirectory>
55+
<abbrevLength>7</abbrevLength>
56+
<gitDescribe>
57+
<skip>true</skip>
58+
</gitDescribe>
59+
</configuration>
60+
</plugin>
61+
62+
<plugin>
63+
<groupId>org.codehaus.mojo</groupId>
64+
<artifactId>animal-sniffer-maven-plugin</artifactId>
65+
<version>${maven.animal.sniffer.plugin.version}</version>
66+
<configuration>
67+
<signature>
68+
<groupId>org.codehaus.mojo.signature</groupId>
69+
<artifactId>java16</artifactId>
70+
<version>1.0</version>
71+
</signature>
72+
<ignores>
73+
<ignore>sun.misc.Unsafe</ignore>
74+
</ignores>
75+
</configuration>
76+
<executions>
77+
<execution>
78+
<id>source-java6-check</id>
79+
<phase>compile</phase>
80+
<goals>
81+
<goal>check</goal>
82+
</goals>
83+
</execution>
84+
</executions>
85+
</plugin>
86+
87+
<plugin>
88+
<groupId>org.apache.maven.plugins</groupId>
89+
<artifactId>maven-source-plugin</artifactId>
90+
<version>${maven.source.plugin.version}</version>
91+
<executions>
92+
<execution>
93+
<id>attach-sources</id>
94+
<goals>
95+
<goal>jar</goal>
96+
</goals>
97+
</execution>
98+
</executions>
99+
</plugin>
100+
101+
<plugin>
102+
<groupId>org.apache.felix</groupId>
103+
<artifactId>maven-bundle-plugin</artifactId>
104+
<version>${maven.bundle.plugin.version}</version>
105+
<executions>
106+
<execution>
107+
<id>bundle-manifest</id>
108+
<phase>process-classes</phase>
109+
<goals>
110+
<goal>manifest</goal>
111+
</goals>
112+
<configuration>
113+
<instructions>
114+
<Bundle-Activator>com.hazelcast.osgi.impl.Activator</Bundle-Activator>
115+
<Export-Package>
116+
com.hazelcast.*
117+
</Export-Package>
118+
<Import-Package>
119+
!org.junit,
120+
!com.hazelcast.*,
121+
!com.eclipsesource.json,
122+
sun.misc;resolution:=optional,
123+
javax.cache;resolution:=optional,
124+
javax.cache.*;resolution:=optional,
125+
org.apache.log4j;resolution:=optional,
126+
org.apache.log4j.spi;resolution:=optional,
127+
org.apache.logging.log4j;resolution:=optional,
128+
org.apache.logging.log4j.spi;resolution:=optional,
129+
org.slf4j;resolution:=optional,
130+
org.codehaus.groovy.jsr223;resolution:=optional,
131+
org.jruby.embed.jsr223;resolution:=optional,
132+
*
133+
</Import-Package>
134+
</instructions>
135+
</configuration>
136+
</execution>
137+
</executions>
138+
</plugin>
139+
140+
<plugin>
141+
<groupId>org.apache.maven.plugins</groupId>
142+
<artifactId>maven-jar-plugin</artifactId>
143+
<version>${maven.jar.plugin.version}</version>
144+
<configuration>
145+
<archive>
146+
<index>true</index>
147+
<compress>true</compress>
148+
<manifest>
149+
<mainClass>com.hazelcast.core.server.StartServer</mainClass>
150+
<!--<addClasspath>true</addClasspath>-->
151+
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
152+
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
153+
</manifest>
154+
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
155+
</archive>
156+
<excludes>
157+
<exclude>**/*.html</exclude>
158+
<exclude>**/*.sh</exclude>
159+
<exclude>**/*.bat</exclude>
160+
<exclude>META-INF/services/javax.annotation.processing.Processor</exclude>
161+
</excludes>
162+
</configuration>
163+
<executions>
164+
<execution>
165+
<goals>
166+
<goal>test-jar</goal>
167+
<!--Need to add sources for this test jar to Maven central. partic TestHazelcastInstanceFactory. Brian request. -->
168+
</goals>
169+
</execution>
170+
</executions>
171+
</plugin>
172+
173+
<plugin>
174+
<groupId>org.apache.maven.plugins</groupId>
175+
<artifactId>maven-clean-plugin</artifactId>
176+
<version>3.0.0</version>
177+
<executions>
178+
<execution>
179+
<phase>clean</phase>
180+
<goals>
181+
<goal>clean</goal>
182+
</goals>
183+
<configuration>
184+
<filesets>
185+
<fileset>
186+
<directory>src/main/java</directory>
187+
<includes>
188+
<include>**/Generated*</include>
189+
</includes>
190+
</fileset>
191+
</filesets>
192+
</configuration>
193+
</execution>
194+
</executions>
195+
</plugin>
196+
</plugins>
197+
</build>
198+
199+
<dependencies>
200+
<dependency>
201+
<groupId>com.hazelcast</groupId>
202+
<artifactId>hazelcast</artifactId>
203+
<version>${project.version}</version>
204+
<scope>compile</scope>
205+
</dependency>
206+
</dependencies>
207+
208+
</project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.hazelcast.raft;
2+
3+
import java.util.Collection;
4+
5+
/**
6+
* TODO: Javadoc Pending...
7+
*
8+
* @author mdogan 30.10.2017
9+
*/
10+
public class RaftConfig {
11+
12+
private Collection<String> addresses;
13+
14+
public Collection<String> getAddresses() {
15+
return addresses;
16+
}
17+
18+
public void setAddresses(Collection<String> addresses) {
19+
this.addresses = addresses;
20+
}
21+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package com.hazelcast.raft;
2+
3+
import com.hazelcast.nio.Address;
4+
5+
import java.util.Collection;
6+
7+
/**
8+
* TODO: Javadoc Pending...
9+
*
10+
*/
11+
public class RaftContext {
12+
13+
final String name;
14+
final Collection<Address> members;
15+
16+
private RaftRole role = RaftRole.FOLLOWER;
17+
private int term;
18+
private Address leader;
19+
20+
private Address votedFor;
21+
private int lastVoteTerm;
22+
23+
public RaftContext(String name, Collection<Address> members) {
24+
this.name = name;
25+
this.members = members;
26+
}
27+
28+
public String name() {
29+
return name;
30+
}
31+
32+
public void role(RaftRole role) {
33+
this.role = role;
34+
}
35+
36+
public Collection<Address> members() {
37+
return members;
38+
}
39+
40+
public RaftRole role() {
41+
return role;
42+
}
43+
44+
public int term() {
45+
return term;
46+
}
47+
48+
public int incTerm() {
49+
return ++term;
50+
}
51+
52+
public Address leader() {
53+
return leader;
54+
}
55+
56+
public void persistVote(int term, Address address) {
57+
this.lastVoteTerm = term;
58+
this.votedFor = address;
59+
}
60+
61+
public void term(int term) {
62+
this.term = term;
63+
}
64+
65+
public int lastVoteTerm() {
66+
return lastVoteTerm;
67+
}
68+
69+
public Address votedFor() {
70+
return votedFor;
71+
}
72+
73+
public int lastLogTerm() {
74+
return 0;
75+
}
76+
77+
public int lastLogIndex() {
78+
return 0;
79+
}
80+
81+
public void leader(Address address) {
82+
leader = address;
83+
}
84+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.hazelcast.raft;
2+
3+
/**
4+
* TODO: Javadoc Pending...
5+
*
6+
* @author mdogan 30.10.2017
7+
*/
8+
public class RaftLog {
9+
}

0 commit comments

Comments
 (0)