Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cs733
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sushant Mahajan
cs733
Commits
57b15e58
Commit
57b15e58
authored
Jan 25, 2015
by
Sushant Mahajan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
per key level versioning and tests modularized
parent
d233a3c1
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
152 additions
and
38 deletions
+152
-38
assignment1/server.go
assignment1/server.go
+14
-10
assignment1/server_test.go
assignment1/server_test.go
+138
-28
No files found.
assignment1/server.go
View file @
57b15e58
...
...
@@ -57,12 +57,12 @@ type KeyValueStore struct {
sync
.
RWMutex
//mutex for synchronization when reading or writing to the hashtable
}
//global version counter
var
ver
uint64
//pointer to custom logger
var
logger
*
log
.
Logger
//cache
var
table
*
KeyValueStore
/*Function to start the server and accept connections.
*arguments: none
*return: none
...
...
@@ -75,7 +75,7 @@ func startServer() {
}
//initialize key value store
table
:
=
&
KeyValueStore
{
dictionary
:
make
(
map
[
string
]
*
Data
)}
table
=
&
KeyValueStore
{
dictionary
:
make
(
map
[
string
]
*
Data
)}
//infinite loop
for
{
...
...
@@ -458,9 +458,8 @@ func performSet(conn net.Conn, tokens []string, table *KeyValueStore, ch chan []
val
=
new
(
Data
)
table
.
dictionary
[
k
]
=
val
}
ver
++
val
.
numBytes
=
n
val
.
version
=
ver
val
.
version
++
if
e
==
0
{
val
.
isPerpetual
=
true
val
.
expTime
=
0
...
...
@@ -561,8 +560,7 @@ func performCas(conn net.Conn, tokens []string, table *KeyValueStore, ch chan []
val
.
expTime
=
e
+
uint64
(
time
.
Now
()
.
Unix
())
}
val
.
numBytes
=
n
ver
++
val
.
version
=
ver
val
.
version
++
val
.
value
=
v
//key found and changed
return
val
.
version
,
0
,
r
...
...
@@ -654,8 +652,6 @@ func CustomSplitter(data []byte, atEOF bool) (advance int, token []byte, err err
*return: none
*/
func
main
()
{
ver
=
1
toLog
:=
""
if
len
(
os
.
Args
)
>
1
{
toLog
=
os
.
Args
[
1
]
...
...
@@ -675,3 +671,11 @@ func main() {
var
input
string
fmt
.
Scanln
(
&
input
)
}
//server will not call this, we'll call it from test cases to clear the map
func
ReInitServer
()
{
for
key
,
_
:=
range
table
.
dictionary
{
delete
(
table
.
dictionary
,
key
)
}
//fmt.Println(table.dictionary)
}
assignment1/server_test.go
View file @
57b15e58
This diff is collapsed.
Click to expand it.
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