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
7254798d
You need to sign in or sign up before continuing.
Commit
7254798d
authored
Aug 20, 2024
by
amir.yosef
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding validation to INFO command
parent
f74874d4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
CommandValidator.java
src/command/CommandValidator.java
+4
-2
InfoCommand.java
src/command/InfoCommand.java
+5
-1
No files found.
src/command/CommandValidator.java
View file @
7254798d
...
@@ -10,7 +10,6 @@ import java.util.stream.IntStream;
...
@@ -10,7 +10,6 @@ import java.util.stream.IntStream;
public
class
CommandValidator
{
public
class
CommandValidator
{
private
CommandValidator
()
{
private
CommandValidator
()
{
}
}
private
static
final
class
InstanceHolder
{
private
static
final
class
InstanceHolder
{
...
@@ -49,8 +48,11 @@ public class CommandValidator {
...
@@ -49,8 +48,11 @@ public class CommandValidator {
}
}
public
boolean
validateGetCommand
(
List
<
String
>
args
)
{
public
boolean
validateGetCommand
(
List
<
String
>
args
)
{
return
args
!=
null
&&
args
.
size
()
==
1
;
return
args
!=
null
&&
args
.
size
()
==
1
;
}
}
public
boolean
validateInfoCommand
(
List
<
String
>
args
)
{
return
args
!=
null
&&
args
.
size
()
==
1
&&
"replication"
.
equalsIgnoreCase
(
args
.
getFirst
());
}
}
}
src/command/InfoCommand.java
View file @
7254798d
package
command
;
package
command
;
import
model.Command
;
import
model.Command
;
import
util.Response
;
import
server.ServerInfo
;
import
server.ServerInfo
;
import
util.Response
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -10,6 +10,7 @@ import java.util.stream.Collectors;
...
@@ -10,6 +10,7 @@ import java.util.stream.Collectors;
public
class
InfoCommand
implements
CommandExecutable
<
byte
[]>
{
public
class
InfoCommand
implements
CommandExecutable
<
byte
[]>
{
private
final
ServerInfo
configuration
=
ServerInfo
.
getInstance
();
private
final
ServerInfo
configuration
=
ServerInfo
.
getInstance
();
private
final
CommandValidator
validator
=
CommandValidator
.
getInstance
();
List
<
String
>
args
;
List
<
String
>
args
;
public
InfoCommand
(
List
<
String
>
args
)
{
public
InfoCommand
(
List
<
String
>
args
)
{
...
@@ -18,6 +19,9 @@ public class InfoCommand implements CommandExecutable<byte[]> {
...
@@ -18,6 +19,9 @@ public class InfoCommand implements CommandExecutable<byte[]> {
@Override
@Override
public
byte
[]
execute
()
{
public
byte
[]
execute
()
{
if
(!
validator
.
validateInfoCommand
(
args
))
{
return
"unsupported args"
.
getBytes
();
}
String
command
=
args
.
getFirst
();
String
command
=
args
.
getFirst
();
if
(
command
.
equalsIgnoreCase
(
Command
.
REPLICATION
.
getValue
()))
{
if
(
command
.
equalsIgnoreCase
(
Command
.
REPLICATION
.
getValue
()))
{
Map
<
String
,
String
>
info
=
configuration
.
getInfo
();
Map
<
String
,
String
>
info
=
configuration
.
getInfo
();
...
...
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