Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
K
key_value-server
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
amir.yosef
key_value-server
Commits
5c89bdef
You need to sign in or sign up before continuing.
Commit
5c89bdef
authored
Aug 13, 2024
by
amir.yosef
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding ServerBuilder
parent
d7c1beda
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
4 deletions
+33
-4
ServerBuilder.java
src/builder/ServerBuilder.java
+26
-0
Server.java
src/server/Server.java
+7
-4
No files found.
src/builder/ServerBuilder.java
0 → 100644
View file @
5c89bdef
package
builder
;
import
server.Server
;
import
java.io.IOException
;
public
class
ServerBuilder
{
private
int
port
;
private
String
role
;
public
void
port
(
int
port
)
{
this
.
port
=
port
;
}
public
void
role
(
String
role
)
{
this
.
role
=
role
;
}
public
Server
build
()
{
try
{
return
Server
.
getInstance
(
port
,
role
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"Failed to build the Server"
);
}
}
}
src/server/Server.java
View file @
5c89bdef
...
...
@@ -10,18 +10,21 @@ import java.util.concurrent.ExecutorService;
import
java.util.concurrent.Executors
;
public
class
Server
{
private
static
final
int
PORT
=
16379
;
private
final
int
PORT
;
private
final
ExecutorService
executor
;
private
final
String
role
;
private
static
Server
instance
;
private
Server
()
{
Server
(
int
port
,
String
role
)
{
PORT
=
port
;
this
.
role
=
role
;
this
.
executor
=
Executors
.
newVirtualThreadPerTaskExecutor
();
}
public
static
synchronized
Server
getInstance
()
throws
IOException
{
public
static
synchronized
Server
getInstance
(
int
PORT
,
String
role
)
throws
IOException
{
if
(
instance
==
null
)
{
instance
=
new
Server
();
instance
=
new
Server
(
PORT
,
role
);
}
return
instance
;
}
...
...
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