Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hpdos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SYNERG
hpdos
Commits
34204c32
Commit
34204c32
authored
Apr 02, 2021
by
NILANJAN DAW
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added heartbeat service and follower autodiscovery
Added backend for in memory data storage
parent
2ff3bcac
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
387 additions
and
11 deletions
+387
-11
code/hpdos_server/.idea/gradle.xml
code/hpdos_server/.idea/gradle.xml
+1
-0
code/hpdos_server/.idea/uiDesigner.xml
code/hpdos_server/.idea/uiDesigner.xml
+124
-0
code/hpdos_server/app/src/main/java/hpdos/ConfigConstants.java
...hpdos_server/app/src/main/java/hpdos/ConfigConstants.java
+7
-0
code/hpdos_server/app/src/main/java/hpdos/MetadataServer.java
.../hpdos_server/app/src/main/java/hpdos/MetadataServer.java
+97
-7
code/hpdos_server/app/src/main/java/hpdos/handler/HeartbeatHandler.java
...ver/app/src/main/java/hpdos/handler/HeartbeatHandler.java
+42
-0
code/hpdos_server/app/src/main/java/hpdos/handler/NetworkHandler.java
...erver/app/src/main/java/hpdos/handler/NetworkHandler.java
+1
-3
code/hpdos_server/app/src/main/java/hpdos/lib/MasterFollower.java
...os_server/app/src/main/java/hpdos/lib/MasterFollower.java
+55
-0
code/hpdos_server/app/src/main/java/hpdos/lib/MemoryStorage.java
...dos_server/app/src/main/java/hpdos/lib/MemoryStorage.java
+23
-0
code/hpdos_server/app/src/main/java/hpdos/lib/StorageService.java
...os_server/app/src/main/java/hpdos/lib/StorageService.java
+6
-0
code/hpdos_server/app/src/main/java/hpdos/messageformat/MessageConstants.java
...p/src/main/java/hpdos/messageformat/MessageConstants.java
+2
-1
code/hpdos_server/app/src/main/proto/Heartbeat.proto
code/hpdos_server/app/src/main/proto/Heartbeat.proto
+29
-0
No files found.
code/hpdos_server/.idea/gradle.xml
View file @
34204c32
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"GradleMigrationSettings"
migrationVersion=
"1"
/>
<component
name=
"GradleSettings"
>
<option
name=
"linkedExternalProjectsSettings"
>
<GradleProjectSettings>
...
...
code/hpdos_server/.idea/uiDesigner.xml
0 → 100644
View file @
34204c32
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"Palette2"
>
<group
name=
"Swing"
>
<item
class=
"com.intellij.uiDesigner.HSpacer"
tooltip-text=
"Horizontal Spacer"
icon=
"/com/intellij/uiDesigner/icons/hspacer.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"1"
hsize-policy=
"6"
anchor=
"0"
fill=
"1"
/>
</item>
<item
class=
"com.intellij.uiDesigner.VSpacer"
tooltip-text=
"Vertical Spacer"
icon=
"/com/intellij/uiDesigner/icons/vspacer.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"1"
anchor=
"0"
fill=
"2"
/>
</item>
<item
class=
"javax.swing.JPanel"
icon=
"/com/intellij/uiDesigner/icons/panel.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"3"
hsize-policy=
"3"
anchor=
"0"
fill=
"3"
/>
</item>
<item
class=
"javax.swing.JScrollPane"
icon=
"/com/intellij/uiDesigner/icons/scrollPane.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"7"
hsize-policy=
"7"
anchor=
"0"
fill=
"3"
/>
</item>
<item
class=
"javax.swing.JButton"
icon=
"/com/intellij/uiDesigner/icons/button.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"3"
anchor=
"0"
fill=
"1"
/>
<initial-values>
<property
name=
"text"
value=
"Button"
/>
</initial-values>
</item>
<item
class=
"javax.swing.JRadioButton"
icon=
"/com/intellij/uiDesigner/icons/radioButton.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"3"
anchor=
"8"
fill=
"0"
/>
<initial-values>
<property
name=
"text"
value=
"RadioButton"
/>
</initial-values>
</item>
<item
class=
"javax.swing.JCheckBox"
icon=
"/com/intellij/uiDesigner/icons/checkBox.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"3"
anchor=
"8"
fill=
"0"
/>
<initial-values>
<property
name=
"text"
value=
"CheckBox"
/>
</initial-values>
</item>
<item
class=
"javax.swing.JLabel"
icon=
"/com/intellij/uiDesigner/icons/label.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"0"
anchor=
"8"
fill=
"0"
/>
<initial-values>
<property
name=
"text"
value=
"Label"
/>
</initial-values>
</item>
<item
class=
"javax.swing.JTextField"
icon=
"/com/intellij/uiDesigner/icons/textField.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"8"
fill=
"1"
>
<preferred-size
width=
"150"
height=
"-1"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JPasswordField"
icon=
"/com/intellij/uiDesigner/icons/passwordField.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"8"
fill=
"1"
>
<preferred-size
width=
"150"
height=
"-1"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JFormattedTextField"
icon=
"/com/intellij/uiDesigner/icons/formattedTextField.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"8"
fill=
"1"
>
<preferred-size
width=
"150"
height=
"-1"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JTextArea"
icon=
"/com/intellij/uiDesigner/icons/textArea.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JTextPane"
icon=
"/com/intellij/uiDesigner/icons/textPane.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JEditorPane"
icon=
"/com/intellij/uiDesigner/icons/editorPane.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JComboBox"
icon=
"/com/intellij/uiDesigner/icons/comboBox.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"2"
anchor=
"8"
fill=
"1"
/>
</item>
<item
class=
"javax.swing.JTable"
icon=
"/com/intellij/uiDesigner/icons/table.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JList"
icon=
"/com/intellij/uiDesigner/icons/list.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"2"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JTree"
icon=
"/com/intellij/uiDesigner/icons/tree.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JTabbedPane"
icon=
"/com/intellij/uiDesigner/icons/tabbedPane.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"3"
hsize-policy=
"3"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"200"
height=
"200"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JSplitPane"
icon=
"/com/intellij/uiDesigner/icons/splitPane.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"3"
hsize-policy=
"3"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"200"
height=
"200"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JSpinner"
icon=
"/com/intellij/uiDesigner/icons/spinner.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"8"
fill=
"1"
/>
</item>
<item
class=
"javax.swing.JSlider"
icon=
"/com/intellij/uiDesigner/icons/slider.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"8"
fill=
"1"
/>
</item>
<item
class=
"javax.swing.JSeparator"
icon=
"/com/intellij/uiDesigner/icons/separator.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
/>
</item>
<item
class=
"javax.swing.JProgressBar"
icon=
"/com/intellij/uiDesigner/icons/progressbar.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"0"
fill=
"1"
/>
</item>
<item
class=
"javax.swing.JToolBar"
icon=
"/com/intellij/uiDesigner/icons/toolbar.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"0"
fill=
"1"
>
<preferred-size
width=
"-1"
height=
"20"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JToolBar$Separator"
icon=
"/com/intellij/uiDesigner/icons/toolbarSeparator.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"0"
anchor=
"0"
fill=
"1"
/>
</item>
<item
class=
"javax.swing.JScrollBar"
icon=
"/com/intellij/uiDesigner/icons/scrollbar.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"0"
anchor=
"0"
fill=
"2"
/>
</item>
</group>
</component>
</project>
\ No newline at end of file
code/hpdos_server/app/src/main/java/hpdos/ConfigConstants.java
View file @
34204c32
package
hpdos
;
public
class
ConfigConstants
{
public
static
final
String
HOST
=
"localhost"
;
public
static
final
int
PORT
=
8080
;
public
static
final
int
HEARTBEAT_INTERVAL
=
500
;
// Backend types 300-399
public
static
final
int
BACKEND_IN_MEMORY
=
300
;
public
static
final
int
LSM_BACKEND
=
301
;
public
static
final
int
BINARY_TREE_BACKEND
=
302
;
}
code/hpdos_server/app/src/main/java/hpdos/MetadataServer.java
View file @
34204c32
...
...
@@ -3,14 +3,42 @@
*/
package
hpdos
;
import
hpdos.grpc.HeartbeatRequest
;
import
hpdos.grpc.HeartbeatResponse
;
import
hpdos.grpc.HeartbeatServiceGrpc
;
import
hpdos.handler.HeartbeatHandler
;
import
hpdos.handler.NetworkHandler
;
import
hpdos.lib.MasterFollower
;
import
hpdos.lib.MemoryStorage
;
import
hpdos.lib.StorageService
;
import
hpdos.messageformat.MessageConstants
;
import
io.grpc.ManagedChannel
;
import
io.grpc.ManagedChannelBuilder
;
import
io.grpc.Server
;
import
io.grpc.ServerBuilder
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
java.util.UUID
;
public
class
MetadataServer
{
private
Server
server
;
private
final
HashMap
<
String
,
MasterFollower
>
followers
;
private
final
String
serverID
;
private
boolean
isMaster
=
false
;
private
int
port
;
private
final
String
host
;
private
StorageService
storageService
;
public
MetadataServer
()
{
this
.
followers
=
new
HashMap
<>();
this
.
serverID
=
UUID
.
randomUUID
().
toString
();
this
.
port
=
10000
+
(
int
)(
Math
.
random
()
*
40000
);
this
.
host
=
"localhost"
;
}
public
String
getGreeting
()
{
return
"Hello World!"
;
}
...
...
@@ -18,6 +46,7 @@ public class MetadataServer {
public
boolean
startServer
()
{
server
=
ServerBuilder
.
forPort
(
ConfigConstants
.
PORT
)
.
addService
(
new
NetworkHandler
())
.
addService
(
new
HeartbeatHandler
(
followers
,
serverID
))
.
build
();
try
{
server
.
start
();
...
...
@@ -38,15 +67,76 @@ public class MetadataServer {
}
}
private
void
announceToMaster
()
{
final
ManagedChannel
channel
=
ManagedChannelBuilder
.
forAddress
(
ConfigConstants
.
HOST
,
ConfigConstants
.
PORT
)
.
usePlaintext
()
.
build
();
HeartbeatServiceGrpc
.
HeartbeatServiceBlockingStub
stub
=
HeartbeatServiceGrpc
.
newBlockingStub
(
channel
);
HeartbeatRequest
.
Builder
heartbeat
=
HeartbeatRequest
.
newBuilder
();
heartbeat
.
setPacketType
(
MessageConstants
.
PACKET_METADATA_REQUEST
);
heartbeat
.
setOperationType
(
MessageConstants
.
MASTER_HEARTBEAT
);
heartbeat
.
setFollowerID
(
this
.
serverID
);
heartbeat
.
setIp
(
this
.
host
);
heartbeat
.
setPort
(
this
.
port
);
try
{
HeartbeatResponse
response
=
stub
.
heartbeat
(
heartbeat
.
build
());
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Metadata Master not found, electing self as master"
);
this
.
isMaster
=
true
;
this
.
port
=
ConfigConstants
.
PORT
;
}
channel
.
shutdown
();
}
private
void
startHeartbeatService
()
{
Timer
timer
=
new
Timer
();
timer
.
scheduleAtFixedRate
(
new
TimerTask
()
{
@Override
public
void
run
()
{
announceToMaster
();
}
},
ConfigConstants
.
HEARTBEAT_INTERVAL
,
ConfigConstants
.
HEARTBEAT_INTERVAL
);
}
private
boolean
initStorage
(
int
backend
)
{
switch
(
backend
)
{
case
ConfigConstants
.
BACKEND_IN_MEMORY
:
this
.
storageService
=
new
MemoryStorage
();
return
true
;
case
ConfigConstants
.
BINARY_TREE_BACKEND
:
case
ConfigConstants
.
LSM_BACKEND
:
default
:
return
false
;
}
}
public
static
void
main
(
String
[]
args
)
{
MetadataServer
metaDataServer
=
new
MetadataServer
();
System
.
out
.
println
(
metaDataServer
.
getGreeting
());
boolean
status
=
metaDataServer
.
startServer
();
if
(
status
)
{
System
.
out
.
println
(
"Starting RPC server at: "
+
ConfigConstants
.
PORT
);
metaDataServer
.
blockForIO
();
System
.
out
.
println
(
"Starting Metadata service"
);
System
.
out
.
println
(
"Initialising storage service"
);
boolean
status
=
metaDataServer
.
initStorage
(
ConfigConstants
.
BACKEND_IN_MEMORY
);
if
(!
status
)
{
System
.
out
.
println
(
"Storage server initialisation error"
);
return
;
}
else
System
.
out
.
println
(
"Failed to create server"
);
System
.
out
.
println
(
"Searching for MetadataMaster"
);
metaDataServer
.
announceToMaster
();
if
(
metaDataServer
.
isMaster
)
{
status
=
metaDataServer
.
startServer
();
System
.
out
.
println
(
"Master ID: "
+
metaDataServer
.
serverID
);
if
(
status
)
{
System
.
out
.
println
(
"Starting RPC server at: "
+
ConfigConstants
.
PORT
);
metaDataServer
.
blockForIO
();
}
else
System
.
out
.
println
(
"Failed to create server"
);
}
else
{
System
.
out
.
println
(
"Master Node detected.\nStarting heartbeat service"
);
metaDataServer
.
startHeartbeatService
();
}
}
}
code/hpdos_server/app/src/main/java/hpdos/handler/HeartbeatHandler.java
0 → 100644
View file @
34204c32
package
hpdos.handler
;
import
hpdos.grpc.HeartbeatRequest
;
import
hpdos.grpc.HeartbeatResponse
;
import
hpdos.grpc.HeartbeatServiceGrpc
;
import
hpdos.lib.MasterFollower
;
import
hpdos.messageformat.MessageConstants
;
import
io.grpc.stub.StreamObserver
;
import
java.io.UnsupportedEncodingException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.Timestamp
;
import
java.time.Instant
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
public
class
HeartbeatHandler
extends
HeartbeatServiceGrpc
.
HeartbeatServiceImplBase
{
private
final
HashMap
<
String
,
MasterFollower
>
followers
;
private
String
serverID
;
public
HeartbeatHandler
(
HashMap
<
String
,
MasterFollower
>
followers
,
String
serverID
)
{
this
.
followers
=
followers
;
this
.
serverID
=
serverID
;
}
@Override
public
void
heartbeat
(
HeartbeatRequest
request
,
StreamObserver
<
HeartbeatResponse
>
heartbeatResponseStreamObserver
)
{
if
(!
followers
.
containsKey
(
request
.
getFollowerID
()))
{
System
.
out
.
println
(
"New follower autodiscovery. Added to system "
+
request
);
followers
.
put
(
request
.
getFollowerID
(),
new
MasterFollower
(
request
.
getIp
(),
request
.
getPort
(),
request
.
getFollowerID
()));
}
else
{
MasterFollower
follower
=
followers
.
get
(
request
.
getFollowerID
());
follower
.
setLastSeen
(
Instant
.
now
().
getEpochSecond
());
}
HeartbeatResponse
.
Builder
response
=
HeartbeatResponse
.
newBuilder
();
response
.
setPacketType
(
MessageConstants
.
PACKET_METADATA_RESPONSE
);
response
.
setOperationType
(
MessageConstants
.
MASTER_HEARTBEAT
);
response
.
setMasterID
(
this
.
serverID
);
heartbeatResponseStreamObserver
.
onNext
(
response
.
build
());
heartbeatResponseStreamObserver
.
onCompleted
();
}
}
code/hpdos_server/app/src/main/java/hpdos/NetworkHandler.java
→
code/hpdos_server/app/src/main/java/hpdos/
handler/
NetworkHandler.java
View file @
34204c32
package
hpdos
;
package
hpdos
.handler
;
import
hpdos.grpc.*
;
import
hpdos.messageformat.*
;
import
io.grpc.stub.StreamObserver
;
import
java.util.ArrayList
;
public
class
NetworkHandler
extends
NetworkServiceGrpc
.
NetworkServiceImplBase
{
...
...
code/hpdos_server/app/src/main/java/hpdos/lib/MasterFollower.java
0 → 100644
View file @
34204c32
package
hpdos.lib
;
import
java.time.Instant
;
public
class
MasterFollower
{
private
String
ip
;
private
int
port
;
private
final
String
followerID
;
private
long
lastSeen
;
public
MasterFollower
(
String
ip
,
int
port
,
String
followerID
)
{
this
.
ip
=
ip
;
this
.
port
=
port
;
this
.
followerID
=
followerID
;
this
.
lastSeen
=
Instant
.
now
().
getEpochSecond
();
}
public
String
getIp
()
{
return
ip
;
}
public
void
setIp
(
String
ip
)
{
this
.
ip
=
ip
;
}
public
int
getPort
()
{
return
port
;
}
public
void
setPort
(
int
port
)
{
this
.
port
=
port
;
}
public
String
getFollowerID
()
{
return
followerID
;
}
public
long
getLastSeen
()
{
return
lastSeen
;
}
public
void
setLastSeen
(
long
lastSeen
)
{
this
.
lastSeen
=
lastSeen
;
}
@Override
public
String
toString
()
{
return
"MasterFollower {"
+
"ip='"
+
ip
+
'\''
+
", port="
+
port
+
", followerID='"
+
followerID
+
'\''
+
'}'
;
}
}
code/hpdos_server/app/src/main/java/hpdos/lib/MemoryStorage.java
0 → 100644
View file @
34204c32
package
hpdos.lib
;
import
java.util.HashMap
;
public
class
MemoryStorage
implements
StorageService
{
private
final
HashMap
<
String
,
String
>
memoryKVStore
;
public
MemoryStorage
()
{
this
.
memoryKVStore
=
new
HashMap
<>();
}
@Override
public
String
put
(
String
key
,
String
value
)
{
try
{
return
memoryKVStore
.
put
(
key
,
value
);
}
catch
(
Exception
e
)
{
return
null
;
}
}
@Override
public
String
getByKey
(
String
key
)
{
return
memoryKVStore
.
get
(
key
);
}
}
code/hpdos_server/app/src/main/java/hpdos/lib/StorageService.java
0 → 100644
View file @
34204c32
package
hpdos.lib
;
public
interface
StorageService
{
String
put
(
String
key
,
String
value
);
String
getByKey
(
String
key
);
}
code/hpdos_server/app/src/main/java/hpdos/messageformat/MessageConstants.java
View file @
34204c32
...
...
@@ -9,7 +9,8 @@ public class MessageConstants {
public
static
final
boolean
STATUS_OK
=
true
;
public
static
final
boolean
STATUS_FAIL
=
false
;
// 101 to 199 - HPDOS System internal operations
// 100 to 199 - HPDOS System internal operations
public
static
final
int
MASTER_HEARTBEAT
=
100
;
public
static
final
int
METADATA_LOOKUP_REQUEST
=
101
;
public
static
final
int
METADATA_LOOKUP_RESPONSE
=
102
;
}
code/hpdos_server/app/src/main/proto/Heartbeat.proto
0 → 100644
View file @
34204c32
syntax
=
"proto3"
;
package
hpdos
.
grpc
;
option
java_multiple_files
=
true
;
option
java_package
=
"hpdos.grpc"
;
option
java_outer_classname
=
"Heartbeat"
;
service
HeartbeatService
{
/**
Exchange heartbeat
*/
rpc
heartbeat
(
HeartbeatRequest
)
returns
(
HeartbeatResponse
)
{}
}
message
HeartbeatRequest
{
int32
packetType
=
1
;
int32
operationType
=
2
;
string
ip
=
3
;
int32
port
=
4
;
string
followerID
=
5
;
}
message
HeartbeatResponse
{
int32
packetType
=
1
;
int32
operationType
=
2
;
bool
status
=
3
;
string
masterID
=
4
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment