Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tapir
Manage
Activity
Members
Labels
Plan
Issues
8
Issue boards
Milestones
Wiki
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
syslab
tapir
Commits
e3631d02
Commit
e3631d02
authored
9 years ago
by
Naveen Kr. Sharma
Browse files
Options
Downloads
Patches
Plain Diff
Adding timeserver to Makefile, and fixing compilation issues
parent
a090e8dd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+3
-2
3 additions, 2 deletions
Makefile
timeserver/timeserver.cc
+59
-63
59 additions, 63 deletions
timeserver/timeserver.cc
timeserver/timeserver.h
+7
-6
7 additions, 6 deletions
timeserver/timeserver.h
with
69 additions
and
71 deletions
Makefile
+
3
−
2
View file @
e3631d02
...
...
@@ -7,8 +7,8 @@ CXX = g++
LD
=
g++
EXPAND
=
lib/tmpl/expand
#
CFLAGS := -g -Wall -pthread -iquote.obj/gen -Wno-uninitialized -O2 -DNASSERT
CFLAGS
:=
-g
-Wall
-pthread
-iquote
.obj/gen
-Wno-uninitialized
CFLAGS
:=
-g
-Wall
-pthread
-iquote
.obj/gen
-Wno-uninitialized
-O2
-DNASSERT
#
CFLAGS := -g -Wall -pthread -iquote.obj/gen -Wno-uninitialized
CXXFLAGS
:=
-g
-std
=
c++0x
LDFLAGS
:=
-levent_pthreads
## Debian package: check
...
...
@@ -131,6 +131,7 @@ include store/strongstore/Rules.mk
include
store/weakstore/Rules.mk
include
store/benchmark/Rules.mk
include
lockserver/Rules.mk
include
timeserver/Rules.mk
include
libtapir/Rules.mk
##################################################################
# General rules
...
...
This diff is collapsed.
Click to expand it.
timeserver/timeserver.cc
+
59
−
63
View file @
e3631d02
...
...
@@ -28,81 +28,77 @@ TimeStampServer::ReplicaUpcall(opnum_t opnum,
string
&
str2
)
{
Debug
(
"Received Upcall: %lu, %s"
,
opnum
,
str1
.
c_str
());
// Get a new timestamp from the TimeStampServer
str2
=
newTimeStamp
();
}
static
void
Usage
(
const
char
*
progName
)
static
void
Usage
(
const
char
*
progName
)
{
fprintf
(
stderr
,
"usage: %s -c conf-file -i replica-index
\n
"
,
progName
);
fprintf
(
stderr
,
"usage: %s -c conf-file -i replica-index
\n
"
,
progName
);
exit
(
1
);
}
int
main
(
int
argc
,
char
**
argv
)
{
int
index
=
-
1
;
const
char
*
configPath
=
NULL
;
// Parse arguments
int
opt
;
while
((
opt
=
getopt
(
argc
,
argv
,
"c:i:"
))
!=
-
1
)
{
switch
(
opt
)
{
case
'c'
:
configPath
=
optarg
;
break
;
case
'i'
:
{
char
*
strtolPtr
;
index
=
strtoul
(
optarg
,
&
strtolPtr
,
10
);
if
((
*
optarg
==
'\0'
)
||
(
*
strtolPtr
!=
'\0'
)
||
(
index
<
0
))
{
fprintf
(
stderr
,
"option -i requires a numeric arg
\n
"
);
Usage
(
argv
[
0
]);
}
break
;
int
index
=
-
1
;
const
char
*
configPath
=
NULL
;
char
*
strtolPtr
;
// Parse arguments
int
opt
;
while
((
opt
=
getopt
(
argc
,
argv
,
"c:i:"
))
!=
-
1
)
{
switch
(
opt
)
{
case
'c'
:
configPath
=
optarg
;
break
;
case
'i'
:
index
=
strtoul
(
optarg
,
&
strtolPtr
,
10
);
if
((
*
optarg
==
'\0'
)
||
(
*
strtolPtr
!=
'\0'
)
||
(
index
<
0
))
{
fprintf
(
stderr
,
"option -i requires a numeric arg
\n
"
);
Usage
(
argv
[
0
]);
}
break
;
default
:
fprintf
(
stderr
,
"Unknown argument %s
\n
"
,
argv
[
optind
]);
break
;
}
}
if
(
!
configPath
)
{
fprintf
(
stderr
,
"option -c is required
\n
"
);
Usage
(
argv
[
0
]);
}
if
(
index
==
-
1
)
{
fprintf
(
stderr
,
"option -i is required
\n
"
);
Usage
(
argv
[
0
]);
}
default
:
fprintf
(
stderr
,
"Unknown argument %s
\n
"
,
argv
[
optind
]);
break
;
// Load configuration
std
::
ifstream
configStream
(
configPath
);
if
(
configStream
.
fail
())
{
fprintf
(
stderr
,
"unable to read configuration file: %s
\n
"
,
configPath
);
Usage
(
argv
[
0
]);
}
}
if
(
!
configPath
)
{
fprintf
(
stderr
,
"option -c is required
\n
"
);
Usage
(
argv
[
0
]);
}
if
(
index
==
-
1
)
{
fprintf
(
stderr
,
"option -i is required
\n
"
);
Usage
(
argv
[
0
]);
}
// Load configuration
std
::
ifstream
configStream
(
configPath
);
if
(
configStream
.
fail
())
{
fprintf
(
stderr
,
"unable to read configuration file: %s
\n
"
,
configPath
);
Usage
(
argv
[
0
]);
}
specpaxos
::
Configuration
config
(
configStream
);
if
(
index
>=
config
.
n
)
{
fprintf
(
stderr
,
"replica index %d is out of bounds; "
"only %d replicas defined
\n
"
,
index
,
config
.
n
);
Usage
(
argv
[
0
]);
}
UDPTransport
transport
(
0.0
,
0.0
,
0
);
TimeStampServer
server
;
specpaxos
::
vr
::
VRReplica
replica
(
config
,
index
,
&
transport
,
1
,
&
server
);
transport
.
Run
();
return
0
;
transport
::
Configuration
config
(
configStream
);
if
(
index
>=
config
.
n
)
{
fprintf
(
stderr
,
"replica index %d is out of bounds; "
"only %d replicas defined
\n
"
,
index
,
config
.
n
);
Usage
(
argv
[
0
]);
}
UDPTransport
transport
(
0.0
,
0.0
,
0
);
TimeStampServer
server
;
replication
::
vr
::
VRReplica
replica
(
config
,
index
,
&
transport
,
1
,
&
server
);
transport
.
Run
();
return
0
;
}
This diff is collapsed.
Click to expand it.
timeserver/timeserver.h
+
7
−
6
View file @
e3631d02
...
...
@@ -9,25 +9,26 @@
#ifndef _TIME_SERVER_H_
#define _TIME_SERVER_H_
#include
"
paxos-lib/
lib/configuration.h"
#include
"
paxos-lib
/common/replica.h"
#include
"
paxos-lib/
lib/udptransport.h"
#include
"
paxos-lib
/vr/replica.h"
#include
"lib/configuration.h"
#include
"
replication
/common/replica.h"
#include
"lib/udptransport.h"
#include
"
replication
/vr/replica.h"
#include
<string>
using
namespace
std
;
class
TimeStampServer
:
public
specpaxos
::
AppReplica
class
TimeStampServer
:
public
replication
::
AppReplica
{
public:
TimeStampServer
();
~
TimeStampServer
();
void
ReplicaUpcall
(
opnum_t
opnum
,
const
string
&
str1
,
string
&
str2
);
private:
long
ts
;
string
newTimeStamp
();
};
#endif
/* _TIME_SERVER_H_ */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment