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
d7f831b2
Commit
d7f831b2
authored
Apr 21, 2021
by
NILANJAN DAW
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Async mode StorageService made cache flag aware. Asyc Storage no more sharing stubs.
parent
fff1436f
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
155 additions
and
125 deletions
+155
-125
code/hpdos_client/app.config
code/hpdos_client/app.config
+1
-0
code/hpdos_client/app/build.gradle
code/hpdos_client/app/build.gradle
+1
-1
code/hpdos_client/app/src/main/java/HpdosClient/ClientRunnerSync.java
...lient/app/src/main/java/HpdosClient/ClientRunnerSync.java
+6
-2
code/hpdos_client/app/src/main/java/HpdosClient/lib/StorageModel.java
...lient/app/src/main/java/HpdosClient/lib/StorageModel.java
+10
-0
code/hpdos_client/app/src/main/java/HpdosClient/lib/StorageService.java
...ent/app/src/main/java/HpdosClient/lib/StorageService.java
+78
-50
code/hpdos_client/app/src/main/java/HpdosClient/lib/StorageServiceSync.java
...app/src/main/java/HpdosClient/lib/StorageServiceSync.java
+59
-41
code/hpdos_client/app/src/test/java/HpdosClient/AppTest.java
code/hpdos_client/app/src/test/java/HpdosClient/AppTest.java
+0
-31
No files found.
code/hpdos_client/app.config
View file @
d7f831b2
app
.
name
=
"HPDOS-Client"
app
.
version
=
"0.1.4"
app
.
cache
=
1
app
.
thread_count
=
10
app
.
rps
=
1000
app
.
runtime
=
10
...
...
code/hpdos_client/app/build.gradle
View file @
d7f831b2
...
...
@@ -53,7 +53,7 @@ dependencies {
application
{
// Define the main class for the application.
mainClass
=
'HpdosClient.ClientRunner
Sync
'
mainClass
=
'HpdosClient.ClientRunner'
}
sourceSets
{
...
...
code/hpdos_client/app/src/main/java/HpdosClient/ClientRunnerSync.java
View file @
d7f831b2
...
...
@@ -38,6 +38,7 @@ public class ClientRunnerSync {
public
boolean
experimentEnded
=
false
;
private
Queue
<
Long
>
createTime
,
updateTime
,
readTime
,
deleteTime
;
private
final
Properties
properties
;
private
boolean
cacheEnabled
;
public
ClientRunnerSync
()
{
clientID
=
UUID
.
randomUUID
().
toString
();
...
...
@@ -46,6 +47,7 @@ public class ClientRunnerSync {
InputStream
inputStream
=
new
FileInputStream
(
propertiesFile
);
properties
.
load
(
inputStream
);
parallelCount
=
Integer
.
parseInt
((
String
)
properties
.
get
(
"app.thread_count"
));
cacheEnabled
=
properties
.
get
(
"app.cache"
).
equals
(
"1"
);
runtime
=
Integer
.
parseInt
((
String
)
properties
.
get
(
"app.runtime"
));
cCreate
=
Integer
.
parseInt
((
String
)
properties
.
get
(
"app.cycle_create"
));
cRead
=
Integer
.
parseInt
((
String
)
properties
.
get
(
"app.cycle_read"
));
...
...
@@ -79,7 +81,7 @@ public class ClientRunnerSync {
return
new
String
(
data
);
}
public
double
runExperiment
(
String
id
,
long
experimentStartTime
)
{
StorageServiceSync
storageService
=
new
StorageServiceSync
(
this
.
clientID
);
StorageServiceSync
storageService
=
new
StorageServiceSync
(
this
.
clientID
,
this
.
cacheEnabled
);
storageService
.
initStorage
();
String
value
=
createString
(),
updatedValue
=
createString
();
for
(;;)
{
...
...
@@ -112,7 +114,8 @@ public class ClientRunnerSync {
if
((
currentTime
-
experimentStartTime
)
>=
runtime
*
1000L
)
break
;
}
System
.
out
.
println
(
storageService
.
getCache
().
stats
());
if
(
this
.
cacheEnabled
)
System
.
out
.
println
(
storageService
.
getCache
().
stats
());
storageService
.
cleanup
();
return
0
;
}
...
...
@@ -174,6 +177,7 @@ public class ClientRunnerSync {
ClientRunnerSync
clientRunner
=
new
ClientRunnerSync
();
System
.
out
.
println
(
clientRunner
.
getGreeting
());
System
.
out
.
println
(
"Using Sync Server. Thread count: "
+
parallelCount
+
" runtime: "
+
runtime
+
"s"
);
System
.
out
.
println
(
"cache status: "
+
clientRunner
.
cacheEnabled
);
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
parallelCount
);
Thread
.
sleep
(
1000
);
// let things settle down a bit
Set
<
Callable
<
Double
>>
callables
=
new
HashSet
<>();
...
...
code/hpdos_client/app/src/main/java/HpdosClient/lib/StorageModel.java
View file @
d7f831b2
...
...
@@ -38,6 +38,16 @@ public class StorageModel {
this
.
crc
=
crc
;
}
public
StorageModel
(
Ack
ack
,
String
owner
,
int
accessType
)
{
this
.
version
=
ack
.
getVersion
();
this
.
dataSize
=
ack
.
getDataSize
();
this
.
value
=
ack
.
getValue
();
this
.
crc
=
ack
.
getCrc
();
this
.
key
=
ack
.
getKey
();
this
.
accessType
=
accessType
;
this
.
owner
=
owner
;
}
public
void
updateData
(
Ack
ack
)
{
this
.
version
=
ack
.
getVersion
();
this
.
dataSize
=
ack
.
getDataSize
();
...
...
code/hpdos_client/app/src/main/java/HpdosClient/lib/StorageService.java
View file @
d7f831b2
This diff is collapsed.
Click to expand it.
code/hpdos_client/app/src/main/java/HpdosClient/lib/StorageServiceSync.java
View file @
d7f831b2
...
...
@@ -28,10 +28,7 @@ import io.grpc.ManagedChannelBuilder;
import
javax.annotation.Nonnull
;
import
java.io.IOException
;
import
java.util.AbstractMap
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.concurrent.ExecutionException
;
public
class
StorageServiceSync
{
...
...
@@ -40,36 +37,39 @@ public class StorageServiceSync {
private
ManagedChannel
masterChannel
;
private
ArrayList
<
ManagedChannel
>
channels
;
private
List
<
Follower
>
replicaSet
;
private
final
LoadingCache
<
String
,
StorageModel
>
cache
;
private
boolean
cacheEnabled
;
private
LoadingCache
<
String
,
StorageModel
>
cache
=
null
;
public
StorageServiceSync
(
String
clientID
)
{
public
StorageServiceSync
(
String
clientID
,
boolean
cacheEnabled
)
{
this
.
clientID
=
clientID
;
this
.
cache
=
CacheBuilder
.
newBuilder
()
.
maximumSize
(
10000
)
.
recordStats
()
.
build
(
new
CacheLoader
<>()
{
@Override
public
StorageModel
load
(
@Nonnull
String
key
)
throws
Exception
{
int
index
=
(
int
)
(
Math
.
random
()
*
channels
.
size
());
NetworkServiceGrpc
.
NetworkServiceBlockingStub
stub
=
NetworkServiceGrpc
.
newBlockingStub
(
channels
.
get
(
index
));
ArrayList
<
Request
>
request
=
new
ArrayList
<>();
request
.
add
(
RequestBuilder
.
buildRequest
(
MessageConstants
.
METADATA_READ
,
0
,
0
,
key
,
0
,
MessageConstants
.
METADATA_ACCESS_PRIVATE
,
clientID
,
""
));
Packet
requestPacket
=
RequestBuilder
.
buildPacket
(
request
);
Packet
responsePacket
=
stub
.
readMetadata
(
requestPacket
);
Response
response
=
responsePacket
.
getResponse
(
0
);
if
(
response
.
getStatus
()
==
MessageConstants
.
STATUS_OK
)
{
Ack
ack
=
response
.
getAck
();
return
new
StorageModel
(
ack
.
getVersion
(),
ack
.
getDataSize
(),
ack
.
getKey
(),
MessageConstants
.
METADATA_ACCESS_PRIVATE
,
clientID
,
ack
.
getCrc
(),
ack
.
getValue
());
}
else
{
throw
new
IOException
(
"Resource not found"
);
this
.
cacheEnabled
=
cacheEnabled
;
if
(
this
.
cacheEnabled
)
this
.
cache
=
CacheBuilder
.
newBuilder
()
.
maximumSize
(
10000
)
.
recordStats
()
.
build
(
new
CacheLoader
<>()
{
@Override
public
StorageModel
load
(
@Nonnull
String
key
)
throws
Exception
{
int
index
=
(
int
)
(
Math
.
random
()
*
channels
.
size
());
NetworkServiceGrpc
.
NetworkServiceBlockingStub
stub
=
NetworkServiceGrpc
.
newBlockingStub
(
channels
.
get
(
index
));
ArrayList
<
Request
>
request
=
new
ArrayList
<>();
request
.
add
(
RequestBuilder
.
buildRequest
(
MessageConstants
.
METADATA_READ
,
0
,
0
,
key
,
0
,
MessageConstants
.
METADATA_ACCESS_PRIVATE
,
clientID
,
""
));
Packet
requestPacket
=
RequestBuilder
.
buildPacket
(
request
);
Packet
responsePacket
=
stub
.
readMetadata
(
requestPacket
);
Response
response
=
responsePacket
.
getResponse
(
0
);
if
(
response
.
getStatus
()
==
MessageConstants
.
STATUS_OK
)
{
Ack
ack
=
response
.
getAck
();
return
new
StorageModel
(
ack
.
getVersion
(),
ack
.
getDataSize
(),
ack
.
getKey
(),
MessageConstants
.
METADATA_ACCESS_PRIVATE
,
clientID
,
ack
.
getCrc
(),
ack
.
getValue
());
}
else
{
throw
new
IOException
(
"Resource not found"
);
}
}
}
});
});
}
...
...
@@ -120,14 +120,31 @@ public class StorageServiceSync {
// read back the metadata
public
Map
.
Entry
<
StorageModel
,
Long
>
read
(
String
key
)
{
long
timestampReadStart
=
System
.
currentTimeMillis
();
try
{
StorageModel
model
=
cache
.
get
(
key
);
return
new
AbstractMap
.
SimpleEntry
<>(
model
,
timestampReadStart
);
}
catch
(
ExecutionException
e
)
{
e
.
printStackTrace
();
if
(
cacheEnabled
)
{
long
timestampReadStart
=
System
.
currentTimeMillis
();
try
{
StorageModel
model
=
cache
.
get
(
key
);
return
new
AbstractMap
.
SimpleEntry
<>(
model
,
timestampReadStart
);
}
catch
(
ExecutionException
e
)
{
e
.
printStackTrace
();
}
return
new
AbstractMap
.
SimpleEntry
<>(
null
,
timestampReadStart
);
}
else
{
int
rnd
=
new
Random
().
nextInt
(
this
.
channels
.
size
());
NetworkServiceGrpc
.
NetworkServiceBlockingStub
stub
=
NetworkServiceGrpc
.
newBlockingStub
(
channels
.
get
(
rnd
));
ArrayList
<
Request
>
request
=
new
ArrayList
<>();
request
.
add
(
RequestBuilder
.
buildRequest
(
MessageConstants
.
METADATA_READ
,
0
,
0
,
key
,
0
,
MessageConstants
.
METADATA_ACCESS_PRIVATE
,
this
.
clientID
,
""
));
Packet
packet
=
RequestBuilder
.
buildPacket
(
request
);
long
timestampReadStart
=
System
.
currentTimeMillis
();
Packet
responsePacket
=
stub
.
readMetadata
(
packet
);
if
(
responsePacket
.
getResponse
(
0
).
getStatus
()
==
MessageConstants
.
STATUS_OK
)
{
StorageModel
model
=
new
StorageModel
(
responsePacket
.
getResponse
(
0
).
getAck
(),
this
.
clientID
,
MessageConstants
.
METADATA_ACCESS_PRIVATE
);
return
new
AbstractMap
.
SimpleEntry
<>(
model
,
timestampReadStart
);
}
return
new
AbstractMap
.
SimpleEntry
<>(
null
,
timestampReadStart
);
}
return
new
AbstractMap
.
SimpleEntry
<>(
null
,
timestampReadStart
);
}
public
long
update
(
String
key
,
String
value
,
int
version
)
{
...
...
@@ -139,7 +156,8 @@ public class StorageServiceSync {
long
timestampCreateStart
=
System
.
currentTimeMillis
();
NetworkServiceGrpc
.
NetworkServiceBlockingStub
masterStub
=
NetworkServiceGrpc
.
newBlockingStub
(
masterChannel
);
Packet
responsePacket
=
masterStub
.
updateMetadata
(
packet
);
if
(
responsePacket
.
getResponse
(
0
).
getStatus
()
==
MessageConstants
.
STATUS_OK
)
if
(
this
.
cacheEnabled
&&
responsePacket
.
getResponse
(
0
).
getStatus
()
==
MessageConstants
.
STATUS_OK
)
cache
.
invalidate
(
key
);
return
timestampCreateStart
;
}
...
...
@@ -153,9 +171,9 @@ public class StorageServiceSync {
long
timestampCreateStart
=
System
.
currentTimeMillis
();
NetworkServiceGrpc
.
NetworkServiceBlockingStub
masterStub
=
NetworkServiceGrpc
.
newBlockingStub
(
masterChannel
);
Packet
responsePacket
=
masterStub
.
deleteMetadata
(
packet
);
if
(
responsePacket
.
getResponse
(
0
).
getStatus
()
==
MessageConstants
.
STATUS_OK
)
if
(
this
.
cacheEnabled
&&
responsePacket
.
getResponse
(
0
).
getStatus
()
==
MessageConstants
.
STATUS_OK
)
cache
.
invalidate
(
key
);
return
timestampCreateStart
;
}
}
code/hpdos_client/app/src/test/java/HpdosClient/AppTest.java
deleted
100644 → 0
View file @
fff1436f
/*
* Copyright 2021 Nilanjan Daw, Synerg Lab, Department of CSE, IIT Bombay
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package
HpdosClient
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
public
class
AppTest
{
@Test
public
void
testAppHasAGreeting
()
{
ClientRunner
classUnderTest
=
new
ClientRunner
();
assertNotNull
(
"app should have a greeting"
,
classUnderTest
.
getGreeting
());
}
}
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