Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
encounters
EncounterBasedCommunication
Commits
bc610edd
Commit
bc610edd
authored
Jul 17, 2018
by
Lily Tsai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added es batch test
parent
cd3b19a8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
203 deletions
+16
-203
ebc_enclave_messaging
ebc_enclave_messaging
+1
-1
ebclibrary/src/main/java/org/mpisws/encounters/EncounterBasedCommunication.java
...va/org/mpisws/encounters/EncounterBasedCommunication.java
+1
-1
ebclibrary/src/main/java/org/mpisws/encounters/encounterhistory/bridges/EncounterEntriesBridge.java
...ters/encounterhistory/bridges/EncounterEntriesBridge.java
+1
-1
ebcutils/src/main/java/org/mpisws/embeddedsocial/ESClient.java
...ils/src/main/java/org/mpisws/embeddedsocial/ESClient.java
+1
-0
ebcutils/src/main/java/org/mpisws/embeddedsocial/TestBatchClient.java
.../main/java/org/mpisws/embeddedsocial/TestBatchClient.java
+11
-199
testapp/src/main/java/org/mpisws/testapp/simulator/SimulationClientBT.java
...java/org/mpisws/testapp/simulator/SimulationClientBT.java
+1
-1
No files found.
ebc_enclave_messaging
@
eb462f82
Compare
9d89587c
...
eb462f82
Subproject commit
9d89587c13406c3fd4a52ac1f6b3067ccc3405c8
Subproject commit
eb462f82708dc82b5c57333b5d5d608a9bc15bc5
ebclibrary/src/main/java/org/mpisws/encounters/EncounterBasedCommunication.java
View file @
bc610edd
...
...
@@ -43,7 +43,7 @@ import java.util.List;
*
**/
public
class
EncounterBasedCommunication
{
public
static
final
long
CHANGE_EPOCH_TIME
=
15
*
60000
;
public
static
final
long
CHANGE_EPOCH_TIME
=
2
*
60000
;
public
static
final
long
SCAN_BATCH_INTERVAL
=
(
long
)
(
2
*
60000
);
public
static
final
int
REQUEST_ENABLE_BT
=
1
;
public
static
final
int
REQUEST_ACCESS_FINE_LOCATION
=
2
;
...
...
ebclibrary/src/main/java/org/mpisws/encounters/encounterhistory/bridges/EncounterEntriesBridge.java
View file @
bc610edd
...
...
@@ -185,7 +185,7 @@ public class EncounterEntriesBridge extends AbstractEncountersBridge<MEncounterE
}
public
List
<
MEncounterEntry
>
getConfirmedEntriesAfterTime
(
long
timestamp
)
{
final
String
[]
selectionArgs
=
new
String
[]
{
String
.
valueOf
(
timestamp
),
String
.
valueOf
(
timestamp
)
};
final
String
[]
selectionArgs
=
new
String
[]
{
String
.
valueOf
(
timestamp
)
};
String
whereClause
=
"("
+
PEncounterEntries
.
Columns
.
timestampEnd
+
" > ? OR "
+
PEncounterEntries
.
Columns
.
timestampEnd
+
" = -1)"
+
" AND "
+
PEncounterEntries
.
Columns
.
sharedSecret
+
" IS NOT NULL"
;
...
...
ebcutils/src/main/java/org/mpisws/embeddedsocial/ESClient.java
View file @
bc610edd
...
...
@@ -527,6 +527,7 @@ public class ESClient {
// set the cursor to continue
continuationCursor
=
r
.
getBody
().
getCursor
();
for
(
CommentView
comment
:
r
.
getBody
().
getData
())
{
System
.
out
.
println
(
"Comments: Got message! "
+
comment
.
getText
());
msgs
.
add
(
new
ESMessage
(
comment
.
getText
(),
""
,
comment
.
getTopicHandle
(),
esuser_client
.
isMe
(
comment
.
getUser
().
getUserHandle
()),
comment
.
getCommentHandle
(),
true
,
comment
.
getCreatedTime
().
getMillis
()));
...
...
ebcutils/src/main/java/org/mpisws/embeddedsocial/TestBatchClient.java
View file @
bc610edd
...
...
@@ -9,6 +9,7 @@ import org.mpisws.embeddedsocial.batchactions.DeleteTopicAction;
import
org.mpisws.embeddedsocial.batchactions.FindUniqueTopicAction
;
import
org.mpisws.embeddedsocial.batchactions.GetBuildAction
;
import
org.mpisws.embeddedsocial.batchactions.SubscribeTopicAction
;
import
org.mpisws.helpers.Coder
;
import
org.mpisws.helpers.Identifier
;
import
java.io.IOException
;
...
...
@@ -22,219 +23,30 @@ import okhttp3.Response;
import
static
java
.
lang
.
System
.
exit
;
import
static
org
.
mpisws
.
embeddedsocial
.
ESClient
.
baseURL
;
import
static
org
.
mpisws
.
helpers
.
Utils
.
hexStringToByteArray
;
/**
* Created by tslilyai on 3/24/18.
*/
public
class
TestBatchClient
{
static
final
String
auth
=
"SocialPlus TK=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIzalNIRVUzNTA4ZVxuR29vZ2xlXG4xMTY4Njc1MTE0MDIxMzc1NzcxNTkiLCJpc3MiOiIzcWdtZzlWUmNaeFxuMmU1YTFjYzgtNWVhYi00ZGJkLThkNmQtNmE4NGVhYjIzMzc0IiwiZXhwIjoxNTQxODQ4MTQ0fQ.PTz69j2BuJB0bROiMK-b6zkpL9VOME0fhGjMPjkrkjQ"
;
static
final
String
auth
=
"SocialPlus TK=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIzalNjZHFzN0paYVxuR29vZ2xlXG4xMTAyMDM3NjQyMDI5ODI4NDk3NTYiLCJpc3MiOiIzcWdtZzlWUmNaeFxuMmU1YTFjYzgtNWVhYi00ZGJkLThkNmQtNmE4NGVhYjIzMzc0IiwiZXhwIjoxNTQ3Mzg1NTA0fQ.DhURO4E5-BEFz_dWMdHZHQLq-E_fZf62_si-UlqF3Ko"
;
static
final
String
topicHandle
=
"3gcpdys3KfY"
;
static
final
String
ss
=
"0E31177095EE530101D89573C8261C14F51A3877D4676F74478F5CAF"
;
public
static
void
main
(
String
[]
args
)
{
int
k
=
6
;
//getBuilds(k);
ESClient
.
getInstance
().
setESCredentials
(
"user"
,
auth
);
ESClient
.
getInstance
().
setESAPIKey
(
"2e5a1cc8-5eab-4dbd-8d6d-6a84eab23374"
);
List
<
Pair
<
Identifier
,
Identifier
>>
titles
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
k
;
i
++)
{
titles
.
add
(
new
ImmutablePair
<>(
new
Identifier
(
String
.
valueOf
(
System
.
currentTimeMillis
()).
getBytes
()),
new
Identifier
(
String
.
valueOf
(
System
.
currentTimeMillis
()).
getBytes
())));
}
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
System
.
out
.
println
(
"Running test "
+
i
);
Thread
t
=
new
Thread
(
new
FindCreateSubscribeTopicsRunnable
(
titles
));
t
.
start
();
try
{
t
.
join
();
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
exit
(
0
);
}
private
static
class
FindCreateSubscribeTopicsRunnable
implements
Runnable
{
private
final
List
<
String
>
foundTopics
;
private
final
List
<
Pair
<
Identifier
,
Identifier
>>
toCreateTopics
;
private
final
List
<
Pair
<
Identifier
,
Identifier
>>
titleTextPairs
;
protected
List
<
String
>
topicHandles
;
public
boolean
doneExecuting
=
false
;
public
FindCreateSubscribeTopicsRunnable
(
List
<
Pair
<
Identifier
,
Identifier
>>
titleTextPairs
)
{
this
.
foundTopics
=
new
ArrayList
<>(
titleTextPairs
.
size
());
this
.
toCreateTopics
=
new
ArrayList
<>(
titleTextPairs
.
size
());
for
(
int
i
=
0
;
i
<
titleTextPairs
.
size
();
i
++)
{
foundTopics
.
add
(
null
);
toCreateTopics
.
add
(
null
);
}
this
.
titleTextPairs
=
titleTextPairs
;
}
@Override
public
void
run
()
{
Response
resp
;
ConcurrentLinkedQueue
<
TopicView
>
toDeleteTopics
=
new
ConcurrentLinkedQueue
<>();
EmbeddedSocialBatchedClientImpl
batchOps
;
CountDownLatch
latch
;
int
batchSize
=
(
int
)
titleTextPairs
.
stream
().
filter
(
s
->
s
!=
null
).
count
();
/* ------------------------------------BATCH 1: FIND --------------------------------------------------------*/
if
(
batchSize
>
0
)
{
batchOps
=
new
EmbeddedSocialBatchedClientImpl
.
Builder
()
.
batchSize
(
batchSize
)
.
baseUrl
(
baseURL
)
.
build
();
latch
=
new
CountDownLatch
(
batchSize
);
// find the topics
for
(
int
i
=
0
;
i
<
titleTextPairs
.
size
();
i
++)
{
if
(
titleTextPairs
.
get
(
i
)
!=
null
)
{
Pair
<
Identifier
,
Identifier
>
titleTextPair
=
titleTextPairs
.
get
(
i
);
new
FindUniqueTopicAction
(
batchOps
,
latch
,
i
,
auth
,
titleTextPair
.
getLeft
(),
titleTextPair
.
getRight
(),
toDeleteTopics
,
toCreateTopics
,
foundTopics
)
.
addToBatch
();
}
}
try
{
resp
=
batchOps
.
issueBatch
();
System
.
out
.
println
(
"BATCH 1: Issued find-topics batch of size "
+
batchSize
+
" : "
+
resp
.
isSuccessful
());
latch
.
await
();
}
catch
(
InterruptedException
|
IOException
e
)
{
e
.
printStackTrace
();
}
}
/* ------------------------------------BATCH 2: CREATE (and DELETE) --------------------------------------------------------*/
batchSize
=
toDeleteTopics
.
size
()
+
toCreateTopics
.
size
();
if
(
batchSize
>
0
)
{
batchOps
=
new
EmbeddedSocialBatchedClientImpl
.
Builder
()
.
batchSize
(
batchSize
)
.
baseUrl
(
baseURL
)
.
build
();
latch
=
new
CountDownLatch
(
batchSize
);
// (1) delete all repeated topics
for
(
TopicView
tv
:
toDeleteTopics
)
{
new
DeleteTopicAction
(
batchOps
,
latch
,
auth
,
tv
.
getTopicHandle
()).
addToBatch
();
}
// (2) create all nonexisting topics
for
(
int
i
=
0
;
i
<
titleTextPairs
.
size
();
i
++)
{
if
(
toCreateTopics
.
get
(
i
)
!=
null
)
{
new
CreateTopicAction
(
batchOps
,
latch
,
i
,
auth
,
toCreateTopics
.
get
(
i
).
getLeft
(),
toCreateTopics
.
get
(
i
).
getRight
(),
foundTopics
)
.
addToBatch
();
}
}
try
{
resp
=
batchOps
.
issueBatch
();
System
.
out
.
println
(
"BATCH 2: Create/Delete "
+
batchSize
+
" : "
+
resp
.
isSuccessful
());
latch
.
await
();
}
catch
(
InterruptedException
|
IOException
e
)
{
e
.
printStackTrace
();
}
new
Thread
(
()
->
{
System
.
out
.
println
(
"Starting!"
);
List
<
ESMessage
>
messages
=
ESClient
.
getInstance
().
getMessagesOnTopic
(
topicHandle
);
for
(
ESMessage
msg
:
messages
)
{
System
.
out
.
println
(
Coder
.
decrypt
(
msg
.
getMsgText
(),
hexStringToByteArray
(
ss
)));
}
/* ------------------------------------BATCH 3: REFIND IF CREATED TO MAKE SURE NO RACE CONDITION----------------------------------*/
toDeleteTopics
.
clear
();
batchSize
=
0
;
for
(
Pair
<
Identifier
,
Identifier
>
topic
:
toCreateTopics
)
{
if
(
topic
!=
null
)
{
batchSize
++;
}
}
if
(
batchSize
>
0
)
{
batchOps
=
new
EmbeddedSocialBatchedClientImpl
.
Builder
()
.
batchSize
(
batchSize
)
.
baseUrl
(
baseURL
)
.
build
();
latch
=
new
CountDownLatch
(
batchSize
);
// make sure that only we created the topics
// we shouldn't want to create again so skip that step (if the topic doesn't exist then we failed and we'll try again later)
for
(
int
i
=
0
;
i
<
titleTextPairs
.
size
();
i
++)
{
if
(
toCreateTopics
.
get
(
i
)
!=
null
)
{
Pair
<
Identifier
,
Identifier
>
titleTextPair
=
titleTextPairs
.
get
(
i
);
new
FindUniqueTopicAction
(
batchOps
,
latch
,
i
,
auth
,
titleTextPair
.
getLeft
(),
titleTextPair
.
getRight
(),
toDeleteTopics
,
null
,
foundTopics
)
.
addToBatch
();
}
}
try
{
resp
=
batchOps
.
issueBatch
();
System
.
out
.
println
(
"BATCH 3: find-topics "
+
batchSize
+
" : "
+
resp
.
isSuccessful
());
latch
.
await
();
}
catch
(
InterruptedException
|
IOException
e
)
{
e
.
printStackTrace
();
}
}
/* ------------------------------------BATCH 4: DELETE EXTRA TOPICS --------------------------------------------------------*/
batchSize
=
toDeleteTopics
.
size
();
if
(
batchSize
>
0
)
{
batchOps
=
new
EmbeddedSocialBatchedClientImpl
.
Builder
()
.
batchSize
(
batchSize
)
.
baseUrl
(
baseURL
)
.
build
();
latch
=
new
CountDownLatch
(
batchSize
);
// delete all repeated topics
for
(
TopicView
tv
:
toDeleteTopics
)
{
new
DeleteTopicAction
(
batchOps
,
latch
,
auth
,
tv
.
getTopicHandle
()).
addToBatch
();
}
try
{
resp
=
batchOps
.
issueBatch
();
System
.
out
.
println
(
"BATCH 4: delete topics "
+
batchSize
+
" : "
+
resp
.
isSuccessful
());
latch
.
await
();
}
catch
(
InterruptedException
|
IOException
e
)
{
e
.
printStackTrace
();
}
}
/* ------------------------------------BATCH 5: SUBSCRIBE --------------------------------------------------------*/
batchSize
=
0
;
for
(
int
i
=
0
;
i
<
titleTextPairs
.
size
();
i
++)
{
if
(
foundTopics
.
get
(
i
)
!=
null
)
batchSize
++;
}
if
(
batchSize
>
0
)
{
batchOps
=
new
EmbeddedSocialBatchedClientImpl
.
Builder
()
.
batchSize
(
batchSize
)
.
baseUrl
(
baseURL
)
.
build
();
latch
=
new
CountDownLatch
(
batchSize
);
for
(
int
i
=
0
;
i
<
titleTextPairs
.
size
();
i
++)
{
if
(
foundTopics
.
get
(
i
)
!=
null
)
{
new
SubscribeTopicAction
(
batchOps
,
latch
,
i
,
auth
,
foundTopics
)
.
addToBatch
();
}
}
try
{
resp
=
batchOps
.
issueBatch
();
System
.
out
.
println
(
"BATCH 5: subscribe topics "
+
batchSize
+
" : "
+
resp
.
isSuccessful
());
latch
.
await
();
}
catch
(
InterruptedException
|
IOException
e
)
{
e
.
printStackTrace
();
}
}
/* BATCH 6: POST MESSAGES ON BAD TOPIC HANDLES */
List
<
ESMessage
>
msgsToPost
=
new
LinkedList
<>();
String
badTopicHandle
=
"3%00j%00e%00E%00a%00_%002%00P%00o%00B%00B%00"
;
String
badData
=
"xlMWN0tyZ0kz1KuOlw3NpcaelNgEztsWei0ZCYHEQS+DViAAWEfbX+qPYH+yuonZ"
;
for
(
int
i
=
0
;
i
<
10
;
i
++)
msgsToPost
.
add
(
new
ESMessage
(
badData
,
badTopicHandle
,
null
,
true
,
null
,
true
,
-
1
));
ESClient
.
getInstance
().
sendMsgs
(
msgsToPost
);
System
.
out
.
println
(
"BATCH 6: send bad messages"
);
topicHandles
=
foundTopics
;
synchronized
(
this
)
{
doneExecuting
=
true
;
notifyAll
();
}
}
}).
start
();
}
public
static
void
getBuilds
(
int
k
)
{
org
.
mpisws
.
embeddedsocial
.
EmbeddedSocialBatchedClientImpl
batchOps
=
new
EmbeddedSocialBatchedClientImpl
.
Builder
()
.
batchSize
(
k
)
...
...
testapp/src/main/java/org/mpisws/testapp/simulator/SimulationClientBT.java
View file @
bc610edd
...
...
@@ -29,7 +29,7 @@ import java.util.UUID;
*/
public
class
SimulationClientBT
{
Context
context
;
protected
static
final
int
NUM_SIMULATED_DEVICES
=
3
0
;
protected
static
final
int
NUM_SIMULATED_DEVICES
=
10
0
;
protected
static
final
int
NUM_SIMULATED_EPOCHS
=
10
;
private
static
final
String
TAG
=
SimulationClientBT
.
class
.
getSimpleName
();
...
...
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