Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
FMS_Project
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
bashar.hussein
FMS_Project
Commits
406501e0
Commit
406501e0
authored
Jul 12, 2023
by
ReemyHasan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Rethink Functions
parent
e0c31d51
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
50 deletions
+46
-50
SnmpListener.java
.../src/main/java/com/example/SnmpReciever/SnmpListener.java
+1
-1
SnmpListener.class
...arget/classes/com/example/SnmpReciever/SnmpListener.class
+0
-0
WebSocketConfig.java
...example/WebApplication/configuration/WebSocketConfig.java
+1
-1
RethinkController.java
.../example/WebApplication/controller/RethinkController.java
+38
-36
SocketTextHandler.java
.../example/WebApplication/controller/SocketTextHandler.java
+2
-8
RethinkDBService.java
...com/example/WebApplication/services/RethinkDBService.java
+4
-4
No files found.
SNMP_Pipeline/SnmpReciever/src/main/java/com/example/SnmpReciever/SnmpListener.java
View file @
406501e0
...
@@ -44,7 +44,7 @@ public class SnmpListener implements CommandResponder {
...
@@ -44,7 +44,7 @@ public class SnmpListener implements CommandResponder {
}
}
public
void
startTrapListener
()
{
public
void
startTrapListener
()
{
try
{
try
{
TransportMapping
<?>
transport
=
new
DefaultUdpTransportMapping
(
new
UdpAddress
(
"192.168.2
6.46
/1625"
));
TransportMapping
<?>
transport
=
new
DefaultUdpTransportMapping
(
new
UdpAddress
(
"192.168.2
5.254
/1625"
));
System
.
out
.
println
(
"Listening to SNMP Trap"
);
System
.
out
.
println
(
"Listening to SNMP Trap"
);
Snmp
snmp
=
new
Snmp
(
transport
);
Snmp
snmp
=
new
Snmp
(
transport
);
snmp
.
addCommandResponder
(
this
);
snmp
.
addCommandResponder
(
this
);
...
...
SNMP_Pipeline/SnmpReciever/target/classes/com/example/SnmpReciever/SnmpListener.class
View file @
406501e0
No preview for this file type
SNMP_Pipeline/Web-Application/src/main/java/com/example/WebApplication/configuration/WebSocketConfig.java
View file @
406501e0
...
@@ -19,7 +19,7 @@ public class WebSocketConfig implements WebSocketConfigurer {
...
@@ -19,7 +19,7 @@ public class WebSocketConfig implements WebSocketConfigurer {
@Override
@Override
public
void
registerWebSocketHandlers
(
WebSocketHandlerRegistry
registry
)
{
public
void
registerWebSocketHandlers
(
WebSocketHandlerRegistry
registry
)
{
System
.
out
.
println
(
webSocketPath
);
//
System.out.println(webSocketPath);
registry
.
addHandler
(
socket_server
,
webSocketPath
).
setAllowedOrigins
(
"*"
);
registry
.
addHandler
(
socket_server
,
webSocketPath
).
setAllowedOrigins
(
"*"
);
}
}
}
}
SNMP_Pipeline/Web-Application/src/main/java/com/example/WebApplication/controller/RethinkController.java
View file @
406501e0
//package com.example.WebApplication.controller;
package
com
.
example
.
WebApplication
.
controller
;
//
//import com.example.WebApplication.controller.SocketTextHandler;
import
com.example.WebApplication.controller.SocketTextHandler
;
//import com.example.WebApplication.entities.RethinkChange;
import
com.example.WebApplication.entities.RethinkChange
;
//import com.example.WebApplication.services.RethinkDBService;
import
com.example.WebApplication.services.RethinkDBService
;
//import com.rethinkdb.net.Cursor;
import
com.rethinkdb.net.Cursor
;
//import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Autowired
;
//import org.springframework.boot.CommandLineRunner;
import
org.springframework.boot.CommandLineRunner
;
//import org.springframework.web.bind.annotation.CrossOrigin;
import
org.springframework.http.HttpStatus
;
//import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.http.ResponseEntity
;
//import org.springframework.web.bind.annotation.RestController;
import
org.springframework.web.bind.annotation.*
;
//
//import java.io.IOException;
import
java.io.IOException
;
//
import
java.util.List
;
//@RestController
import
java.util.Map
;
//@RequestMapping("/api/rethink")
//public class RethinkController {
@RestController
//
@RequestMapping
(
"/api/rethink"
)
// @Override
@CrossOrigin
(
origins
=
{
"http://localhost:3000"
})
// public void run(String... args) throws Exception {
public
class
RethinkController
{
// Cursor<RethinkChange> changeCursor = rethinkDBService.subscribe();
@Autowired
// System.out.println("I am Subscribing");
private
RethinkDBService
rethinkDBService
;
// //List<RethinkChange> result = new ArrayList<>();
@PostMapping
(
"/delete"
)
// for (RethinkChange change : changeCursor){
public
void
delete
(
@RequestBody
String
id
){
//// System.out.println("Something Changed ");
rethinkDBService
.
deleteById
(
id
);
//// System.out.println(change);
}
//// result.add(change);
// try {
@GetMapping
(
"/data"
)
// socket_server.broadcast(change);
public
ResponseEntity
<
List
<
Map
<
String
,
Object
>>>
getData
()
{
// } catch (IOException e) {
List
<
Map
<
String
,
Object
>>
result
=
rethinkDBService
.
getData
();
// throw new RuntimeException(e);
System
.
out
.
println
(
result
);
// }
if
(
result
!=
null
)
{
// }
return
ResponseEntity
.
ok
(
result
);
//
}
else
{
// }
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
build
();
//}
}
}
}
SNMP_Pipeline/Web-Application/src/main/java/com/example/WebApplication/controller/SocketTextHandler.java
View file @
406501e0
...
@@ -25,8 +25,6 @@ import java.util.Map;
...
@@ -25,8 +25,6 @@ import java.util.Map;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.concurrent.CopyOnWriteArrayList
;
@Component
@Component
@RestController
@RequestMapping
(
"/api/rethink"
)
public
class
SocketTextHandler
extends
TextWebSocketHandler
implements
CommandLineRunner
{
public
class
SocketTextHandler
extends
TextWebSocketHandler
implements
CommandLineRunner
{
private
List
<
WebSocketSession
>
sessions
=
new
CopyOnWriteArrayList
<>();
private
List
<
WebSocketSession
>
sessions
=
new
CopyOnWriteArrayList
<>();
...
@@ -98,8 +96,8 @@ public class SocketTextHandler extends TextWebSocketHandler implements CommandLi
...
@@ -98,8 +96,8 @@ public class SocketTextHandler extends TextWebSocketHandler implements CommandLi
public
void
run
(
String
...
args
)
throws
Exception
{
public
void
run
(
String
...
args
)
throws
Exception
{
Cursor
<
RethinkChange
>
changeCursor
=
rethinkDBService
.
subscribe
();
Cursor
<
RethinkChange
>
changeCursor
=
rethinkDBService
.
subscribe
();
System
.
out
.
println
(
"I am Subscribing"
);
System
.
out
.
println
(
"I am Subscribing"
);
System
.
out
.
println
(
changeCursor
.
getClass
());
//
System.out.println(changeCursor.getClass());
System
.
out
.
println
(
changeCursor
);
//
System.out.println(changeCursor);
//List<RethinkChange> result = new ArrayList<>();
//List<RethinkChange> result = new ArrayList<>();
for
(
RethinkChange
change
:
changeCursor
){
for
(
RethinkChange
change
:
changeCursor
){
System
.
out
.
println
(
"Something Changed "
);
System
.
out
.
println
(
"Something Changed "
);
...
@@ -112,8 +110,4 @@ public class SocketTextHandler extends TextWebSocketHandler implements CommandLi
...
@@ -112,8 +110,4 @@ public class SocketTextHandler extends TextWebSocketHandler implements CommandLi
}
}
}
}
@PostMapping
(
"/delete"
)
public
void
delete
(
@RequestBody
String
id
){
rethinkDBService
.
deleteById
(
id
);
}
}
}
SNMP_Pipeline/Web-Application/src/main/java/com/example/WebApplication/services/RethinkDBService.java
View file @
406501e0
...
@@ -34,10 +34,10 @@ public class RethinkDBService{
...
@@ -34,10 +34,10 @@ public class RethinkDBService{
String
jsonString
=
objectMapper
.
writeValueAsString
(
rethinkTrap
);
String
jsonString
=
objectMapper
.
writeValueAsString
(
rethinkTrap
);
JsonNode
jsonNode
=
objectMapper
.
readTree
(
jsonString
);
JsonNode
jsonNode
=
objectMapper
.
readTree
(
jsonString
);
Map
<
String
,
EnrichedTrap
>
document
=
objectMapper
.
convertValue
(
jsonNode
,
Map
.
class
);
Map
<
String
,
EnrichedTrap
>
document
=
objectMapper
.
convertValue
(
jsonNode
,
Map
.
class
);
System
.
out
.
println
(
jsonString
);
//
System.out.println(jsonString);
System
.
out
.
println
(
jsonNode
);
//
System.out.println(jsonNode);
System
.
out
.
println
(
document
);
//
System.out.println(document);
System
.
out
.
println
(
"I am here reem "
+
connectionFactory
.
getDbName
()
+
" "
+
connectionFactory
.
getDbTableName
());
//
System.out.println("I am here reem " + connectionFactory.getDbName() + " " + connectionFactory.getDbTableName());
r
.
db
(
connectionFactory
.
getDbName
()).
table
(
connectionFactory
.
getDbTableName
()).
insert
(
document
).
run
(
connectionFactory
.
getConnection
());
r
.
db
(
connectionFactory
.
getDbName
()).
table
(
connectionFactory
.
getDbTableName
()).
insert
(
document
).
run
(
connectionFactory
.
getConnection
());
System
.
out
.
println
(
"I am here now reem"
);
System
.
out
.
println
(
"I am here now reem"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
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