Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
public static final String SYSTEM_ENDPOINT = "/stomp/v0";
public static final String STREAMS_TOPIC = TOPIC + "/streams";
public static final String STRUCTURE_EVENTS_TOPIC = TOPIC + "/structure-events";
public static final String TIMEBASE_STATUS_TOPIC = TOPIC + "/timebase-status";
public static final String FLOWCHART_TOPIC = TOPIC + "/flowchart";
public static final String FLOWCHART_METADATA_TOPIC = FLOWCHART_TOPIC + "/metadata";
public static final String FLOWCHART_RING_CENTER_TOPIC = FLOWCHART_TOPIC + "/ringCenter";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
@CrossOrigin
public class GenAiController implements SubscriptionController {

private static final String TB_HEADER = "tbId";

private final @Nullable GenAiService genAiService;

public GenAiController(SubscriptionControllerRegistry registry,
public GenAiController(SubscriptionControllerRegistry subscriptionRegistry,
@Autowired(required = false) @Nullable GenAiService genAiService) {
registry.register(WebSocketConfig.GENAI_QQL_TOPIC, this);
subscriptionRegistry.register(WebSocketConfig.GENAI_QQL_TOPIC, this);
this.genAiService = genAiService;
}

Expand All @@ -65,7 +67,8 @@ public Subscription onSubscribe(SimpMessageHeaderAccessor headerAccessor, Subscr
return () -> {};
}

genAiService.subscribe(username, userInput, rawStreamKeys, channel);
String tb = headerAccessor.getFirstNativeHeader(TB_HEADER);
genAiService.subscribe(username, userInput, rawStreamKeys, channel, tb);
return () -> genAiService.unsubscribe(channel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,27 @@ public GrafanaVersion grafanaVersion() {
@RequestMapping(value = "/streams", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<DynamicList> streams(@RequestParam(required = false, defaultValue = "") String template,
@RequestParam(required = false, defaultValue = "0") int offset,
@RequestParam(required = false, defaultValue = "30") int limit) {
return ResponseEntity.ok(grafanaService.listStreams(template, offset, limit));
@RequestParam(required = false, defaultValue = "30") int limit,
@RequestParam(required = false) String tb) {
return ResponseEntity.ok(grafanaService.listStreams(template, offset, limit, tb));
}

@PreAuthorize("hasAnyAuthority('TB_ALLOW_READ', 'TB_ALLOW_WRITE')")
@RequestMapping(value = "/symbols", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<DynamicList> symbols(@RequestParam String stream,
@RequestParam(required = false, defaultValue = "") String template,
@RequestParam(required = false, defaultValue = "0") int offset,
@RequestParam(required = false, defaultValue = "30") int limit)
@RequestParam(required = false, defaultValue = "30") int limit,
@RequestParam(required = false) String tb)
throws NoSuchStreamException {
return ResponseEntity.ok(grafanaService.listSymbols(stream, template, offset, limit));
return ResponseEntity.ok(grafanaService.listSymbols(stream, template, offset, limit, tb));
}

@PreAuthorize("hasAnyAuthority('TB_ALLOW_READ', 'TB_ALLOW_WRITE')")
@RequestMapping(value = "/schema", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<StreamSchema> schema(@RequestParam String stream) throws NoSuchStreamException {
return ResponseEntity.ok(grafanaService.schema(stream));
public ResponseEntity<StreamSchema> schema(@RequestParam String stream,
@RequestParam(required = false) String tb) throws NoSuchStreamException {
return ResponseEntity.ok(grafanaService.schema(stream, tb));
}

@PreAuthorize("hasAnyAuthority('TB_ALLOW_READ', 'TB_ALLOW_WRITE')")
Expand All @@ -87,20 +90,23 @@ public List<String> groupByOptions() {
}

@RequestMapping(value = "/queries/selectTS", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public List<TimeSeriesEntry> selectTS(@Valid @RequestBody DataQueryRequest<SelectQuery> request) throws ValidationException, RecordValidationException {
return grafanaService.timeSeries(request);
public List<TimeSeriesEntry> selectTS(@Valid @RequestBody DataQueryRequest<SelectQuery> request,
@RequestParam(required = false) String tb) throws ValidationException, RecordValidationException {
return grafanaService.timeSeries(request, tb);
}

@PreAuthorize("hasAnyAuthority('TB_ALLOW_READ', 'TB_ALLOW_WRITE')")
@RequestMapping(value = "/queries/selectDF", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public List<DataFrame> selectDataFrame(@Valid @RequestBody DataQueryRequest<SelectQuery> request) throws ValidationException, RecordValidationException {
return grafanaService.dataFrames(request);
public List<DataFrame> selectDataFrame(@Valid @RequestBody DataQueryRequest<SelectQuery> request,
@RequestParam(required = false) String tb) throws ValidationException, RecordValidationException {
return grafanaService.dataFrames(request, tb);
}

@PreAuthorize("hasAnyAuthority('TB_ALLOW_READ', 'TB_ALLOW_WRITE')")
@RequestMapping(value = "/queries/select", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public List<Object> select(@Valid @RequestBody DataQueryRequest<SelectQuery> request) throws ValidationException, RecordValidationException {
return grafanaService.select(request);
public List<Object> select(@Valid @RequestBody DataQueryRequest<SelectQuery> request,
@RequestParam(required = false) String tb) throws ValidationException, RecordValidationException {
return grafanaService.select(request, tb);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ public ImportCsvController(SubscriptionControllerRegistry registry, CsvImportSer

@PreAuthorize("hasAuthority('TB_ALLOW_WRITE')")
@PostMapping(value = "/csv/init")
public ResponseEntity<?> initImport(@RequestParam String streamKey) throws UnknownStreamException {
public ResponseEntity<?> initImport(@RequestParam String streamKey,
@RequestParam(required = false) String tb) throws UnknownStreamException {
if (TextUtils.isEmpty(streamKey))
throw new UnknownStreamException(streamKey);
String id = importService.initImport(streamKey);
String id = importService.initImport(streamKey, tb);
LOGGER.info().append("CSV Import initialization for stream ").append(streamKey)
.append(". Import Id: ").append(id).commit();
return new ResponseEntity<>(Collections.singletonList(id), HttpStatus.CREATED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public long initImport(@Valid @RequestBody ImportRequest importRequest) {
importRequest.to != null ? importRequest.to.toEpochMilli() : Long.MAX_VALUE,
getPeriodicity(importRequest.periodicity),
importRequest.fileBySymbol,
importRequest.writeMode
importRequest.writeMode,
importRequest.tbId
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ public Subscription onSubscribe(SimpMessageHeaderAccessor headerAccessor, Subscr
List<String> symbols = headerAccessorHelper.getSymbols(headerAccessor);
List<String> types = headerAccessorHelper.getTypes(headerAccessor);
JsonBigIntEncoding bigIntEncoding = HeaderAccessorHelper.getJsonBigIntEncoding(headerAccessor);
String tb = headerAccessor.getFirstNativeHeader("tbId");

monitorService.subscribe(sessionId, subscriptionId, stream, null, fromTimestamp, types, symbols, channel::sendMessage, bigIntEncoding);
monitorService.subscribe(sessionId, subscriptionId, stream, null, fromTimestamp, types, symbols, channel::sendMessage, bigIntEncoding, tb);
return () -> monitorService.unsubscribe(sessionId, subscriptionId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public Subscription onSubscribe(SimpMessageHeaderAccessor headerAccessor, Subscr
List<String> types = headerAccessorHelper.getTypes(headerAccessor);
JsonBigIntEncoding bigIntEncoding = HeaderAccessorHelper.getJsonBigIntEncoding(headerAccessor);

monitorService.subscribe(sessionId, subscriptionId, null, qql, fromTimestamp, types, symbols, channel::sendMessage, bigIntEncoding);
String tbId = headerAccessor.getFirstNativeHeader("tbId");
monitorService.subscribe(sessionId, subscriptionId, null, qql, fromTimestamp, types, symbols, channel::sendMessage, bigIntEncoding, tbId);
return () -> monitorService.unsubscribe(sessionId, subscriptionId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ public class OrderBookController implements SubscriptionController {
private static final String SOURCE_HEADER = "source";
private static final String STREAMS_LIST_HEADER = "streams";
private static final String HIDDEN_EXCHANGES_LIST_HEADER = "hiddenExchanges";
private static final String TB_HEADER = "tbId";

private final OrderBookService orderBookService;

private final ObjectMapper objectMapper = new ObjectMapper();

@Autowired
public OrderBookController(SubscriptionControllerRegistry registry, OrderBookService orderBookService) {
registry.register(WebSocketConfig.ORDER_BOOK_TOPIC, this);
public OrderBookController(SubscriptionControllerRegistry subscriptionRegistry, OrderBookService orderBookService) {
subscriptionRegistry.register(WebSocketConfig.ORDER_BOOK_TOPIC, this);
this.orderBookService = orderBookService;
}

Expand All @@ -67,7 +68,7 @@ public Subscription onSubscribe(SimpMessageHeaderAccessor headerAccessor, Subscr
}

private OrderBookSubscriptionOptions getSubscriptionOptions(SimpMessageHeaderAccessor headerAccessor,
SubscriptionChannel channel){
SubscriptionChannel channel) {
String instrument = headerAccessor.getFirstNativeHeader(INSTRUMENT_HEADER);
if (instrument == null || instrument.isEmpty()) {
throw new IllegalArgumentException("Unknown instrument, specify '" + INSTRUMENT_HEADER + "' STOMP header.");
Expand Down Expand Up @@ -115,8 +116,10 @@ private Subscription subscribe(SimpMessageHeaderAccessor headerAccessor, Subscri
.append("; SessionId: ").append(sessionId)
.append("; SubscriptionId: ").append(subscriptionId).commit();

String tb = headerAccessor.getFirstNativeHeader(TB_HEADER);
orderBookService.subscribe(
sessionId, subscriptionId, so.getInstrument(), so.getStreams(), so.getHiddenExchanges(),
tb,
(l2PackageDto) -> {
if (LOG.isTraceEnabled()) {
LOG.trace().append("Sending L2PackageDto for instrument ").append(so.getInstrument())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ public class PlaybackController implements SubscriptionController {
private final PlaybackServiceImpl playbackService;

@Autowired
public PlaybackController(SubscriptionControllerRegistry registry, PlaybackServiceImpl playbackService) {
registry.register(WebSocketConfig.PLAYBACK_TOPIC, this);
public PlaybackController(SubscriptionControllerRegistry subscriptionRegistry,
PlaybackServiceImpl playbackService) {
subscriptionRegistry.register(WebSocketConfig.PLAYBACK_TOPIC, this);
this.playbackService = playbackService;
}

Expand All @@ -70,6 +71,8 @@ public ResponseEntity<Long> createPlayback(@RequestBody PlaybackRequest request,
config.setCyclic(request.isCyclic());
config.setTargetTopic(request.isTargetTopic());
config.setPermanent(request.isPermanent());
config.setSourceTb(request.getSourceTb());
config.setTargetTb(request.getTargetTb());
return new ResponseEntity<>(playbackService.createPlayer(config, user.getName()), HttpStatus.CREATED);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ public ResponseEntity<TreeNodeDef> tree(@RequestBody TimeBaseStructureRequestDef
@PreAuthorize("hasAnyAuthority('TB_ALLOW_READ', 'TB_ALLOW_WRITE')")
@RequestMapping(value = "/{stream}/{symbol}", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<TreeNodeDef> getSymbolTree(@PathVariable String stream, @PathVariable String symbol, @RequestBody TimeBaseStructureRequestDef request) {
public ResponseEntity<TreeNodeDef> getSymbolTree(
@PathVariable String stream,
@PathVariable String symbol,
@RequestParam(required = false) String tb,
@RequestBody TimeBaseStructureRequestDef request) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(
timeBaseTree.findSymbolTree(stream, symbol, request.isShowSpaces(), request.isViews())
timeBaseTree.findSymbolTree(tb, stream, symbol, request.isShowSpaces(), request.isViews())
);
}

Expand Down
Loading
Loading