Skip to content

Commit

Permalink
Merge pull request #160 from SoftwareAG/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
switschel authored Jun 7, 2024
2 parents 7c2cd2b + 68d6413 commit 5a035d3
Show file tree
Hide file tree
Showing 22 changed files with 167 additions and 164 deletions.
2 changes: 1 addition & 1 deletion dynamic-mapping-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<dependency>
<groupId>com.ibm.jsonata4java</groupId>
<artifactId>JSONata4Java</artifactId>
<version>2.4.9</version>
<version>2.5.0</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
@Component
public class C8YNotificationSubscriber {
private final static String WEBSOCKET_PATH = "/notification2/consumer/?token=";
private final static Integer TOKEN_REFRESH_INTERVAL_IN_H = 12;
private final static Integer RECONNECT_INTERVAL_IN_SEC = 60;

@Autowired
private TokenApi tokenApi;
Expand Down Expand Up @@ -491,10 +493,14 @@ public void addConnector(String tenant, String connectorIdent, AsynchronousDispa

public void disconnect(String tenant) {
// Stop WS Reconnect Thread
if (this.executorService != null)
if (this.executorService != null) {
this.executorService.shutdownNow();
if (this.executorTokenService != null)
this.executorService = null;
}
if (this.executorTokenService != null) {
this.executorTokenService.shutdownNow();
this.executorTokenService = null;
}
if (deviceClientMap.get(tenant) != null) {
for (CustomWebSocketClient device_client : deviceClientMap.get(tenant).values()) {
if (device_client != null && device_client.isOpen()) {
Expand All @@ -516,21 +522,24 @@ public CustomWebSocketClient connect(String token, NotificationCallback callback
final CustomWebSocketClient client = new CustomWebSocketClient(webSocketUrl, callback, tenant);
client.setConnectionLostTimeout(30);
client.connect();
configurationRegistry.getC8yAgent().sendNotificationLifecycle(tenant, ConnectorStatus.CONNECTING, null);

// wsClientList.add(client);
// Only start it once
if (this.executorService == null) {
this.executorService = Executors.newScheduledThreadPool(1);
configurationRegistry.getC8yAgent().sendNotificationLifecycle(tenant, ConnectorStatus.CONNECTING, null);
this.executorService.scheduleAtFixedRate(() -> {
reconnect();
}, 120, 30, TimeUnit.SECONDS);
}, 120, RECONNECT_INTERVAL_IN_SEC, TimeUnit.SECONDS);
}

if (this.executorTokenService == null) {
this.executorTokenService = Executors.newScheduledThreadPool(1);
this.executorTokenService = Executors.newScheduledThreadPool(1);
this.executorTokenService.scheduleAtFixedRate(() -> {
refreshTokens();
}, 5, 60, TimeUnit.MINUTES);
}, TOKEN_REFRESH_INTERVAL_IN_H, TOKEN_REFRESH_INTERVAL_IN_H, TimeUnit.HOURS);
}

return client;
} catch (Exception e) {
log.error("Tenant {} - Error on connect to WS {}", tenant, e.getLocalizedMessage());
Expand Down
2 changes: 1 addition & 1 deletion dynamic-mapping-ui/src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ if (__MODE__ === 'production') {
export function bootstrap() {
return platformBrowserDynamic()
.bootstrapModule(AppModule)
.catch(err => console.log(err));
.catch(err => console.error(err));
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class BrokerConfigurationComponent implements OnInit, OnDestroy {
) {}

async ngOnInit() {
console.log('Running version', this.version);
//console.log('Running version', this.version);
this.serviceForm = new FormGroup({
logPayload: new FormControl(''),
logSubstitution: new FormControl(''),
Expand Down Expand Up @@ -124,7 +124,7 @@ export class BrokerConfigurationComponent implements OnInit, OnDestroy {
const response1 = await this.brokerConfigurationService.runOperation(
Operation.REFRESH_NOTIFICATIONS_SUBSCRIPTIONS
);
console.log('Details reconnect2NotificationEndpoint', response1);
//console.log('Details reconnect2NotificationEndpoint', response1);
if (response1.status === 201) {
this.alert.success(gettext('Reconnected successfully.'));
} else {
Expand All @@ -144,7 +144,7 @@ export class BrokerConfigurationComponent implements OnInit, OnDestroy {
initialState
});
modalRef.content.closeSubject.subscribe(async (editedConfiguration) => {
console.log('Configuration after edit:', editedConfiguration);
//console.log('Configuration after edit:', editedConfiguration);
if (editedConfiguration) {
this.configurations[index] = editedConfiguration;
// avoid to include status$
Expand Down Expand Up @@ -190,7 +190,7 @@ export class BrokerConfigurationComponent implements OnInit, OnDestroy {
initialState
});
modalRef.content.closeSubject.subscribe(async (editedConfiguration) => {
console.log('Configuration after edit:', editedConfiguration);
//console.log('Configuration after edit:', editedConfiguration);
if (editedConfiguration) {
this.configurations[index] = editedConfiguration;
// avoid to include status$
Expand Down Expand Up @@ -234,7 +234,7 @@ export class BrokerConfigurationComponent implements OnInit, OnDestroy {
);
confirmDeletionModalRef.content.closeSubject.subscribe(
async (result: boolean) => {
console.log('Confirmation result:', result);
//console.log('Confirmation result:', result);
if (result) {
const response =
await this.brokerConfigurationService.deleteConnectorConfiguration(
Expand Down Expand Up @@ -270,7 +270,7 @@ export class BrokerConfigurationComponent implements OnInit, OnDestroy {
initialState
});
modalRef.content.closeSubject.subscribe(async (addedConfiguration) => {
console.log('Configuration after edit:', addedConfiguration);
//console.log('Configuration after edit:', addedConfiguration);
if (addedConfiguration) {
this.configurations.push(addedConfiguration);
// avoid to include status$
Expand Down Expand Up @@ -303,7 +303,7 @@ export class BrokerConfigurationComponent implements OnInit, OnDestroy {
configuration.enabled ? Operation.DISCONNECT : Operation.CONNECT,
{ connectorIdent: configuration.ident }
);
console.log('Details toggle activation to broker', response1);
//console.log('Details toggle activation to broker', response1);
if (response1.status === 201) {
// if (response1.status === 201 && response2.status === 201) {
this.alert.success(gettext('Connection updated successfully.'));
Expand Down Expand Up @@ -332,7 +332,7 @@ export class BrokerConfigurationComponent implements OnInit, OnDestroy {

confirmDeletionModalRef.content.closeSubject.subscribe(
async (result: boolean) => {
console.log('Confirmation result:', result);
//console.log('Confirmation result:', result);
if (result) {
const res = await this.brokerConfigurationService.runOperation(
Operation.RESET_STATUS_MAPPING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ export class EditConfigurationComponent implements OnInit {
}

onDismiss() {
console.log('Dismiss');
//console.log('Dismiss');
this.closeSubject.next(undefined);
}

onSave() {
console.log('Save');
//console.log('Save');
this.closeSubject.next(this.configuration);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class BrokerConfigurationService {
if (!this._agentId) {
this._agentId = await this.sharedService.getDynamicMappingServiceAgent();
}
console.log('Stop subscriptions:', this._agentId);
//console.log('Stop subscriptions:', this._agentId);
this.realtime.unsubscribe(this.subscriptionEvents);
}

Expand Down Expand Up @@ -182,12 +182,12 @@ export class BrokerConfigurationService {
if (!this._agentId) {
this._agentId = await this.sharedService.getDynamicMappingServiceAgent();
}
console.log(
'Calling: BrokerConfigurationService.initConnectorLogsRealtime()',
this._agentId
);
//console.log(
// 'Calling: BrokerConfigurationService.initConnectorLogsRealtime()',
// this._agentId
//);
const sourceList$ = this.triggerLogs$.pipe(
tap((x) => console.log('TriggerLogs In', x)),
//tap((x) => console.log('TriggerLogs In', x)),
switchMap(() => {
const filter = {
pageSize: 5,
Expand Down Expand Up @@ -245,7 +245,7 @@ export class BrokerConfigurationService {
scan((acc, val) => {
let sortedAcc;
if (val[0]?.type == 'reset') {
console.log('Reset loaded logs!');
//console.log('Reset loaded logs!');
sortedAcc = [];
} else {
sortedAcc = val.concat(acc);
Expand All @@ -260,7 +260,7 @@ export class BrokerConfigurationService {
if (!this._agentId) {
this._agentId = await this.sharedService.getDynamicMappingServiceAgent();
}
console.log('Started subscriptions:', this._agentId);
//console.log('Started subscriptions:', this._agentId);

// subscribe to event stream
this.subscriptionEvents = this.realtime.subscribe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class ExtensionCardComponent implements OnInit {
this.router.navigate(['properties/', this.app.id], {
relativeTo: this.activatedRoute
});
console.log('Details clicked now:', this.app.id);
//console.log('Details clicked now:', this.app.id);
}

async delete() {
Expand All @@ -72,7 +72,7 @@ export class ExtensionCardComponent implements OnInit {
);
confirmDeletionModalRef.content.closeSubject.subscribe(
async (confirmation: boolean) => {
console.log('Confirmation result:', confirmation);
//console.log('Confirmation result:', confirmation);
if (confirmation) {
try {
await this.extensionService.deleteExtension(this.app);
Expand Down
6 changes: 3 additions & 3 deletions dynamic-mapping-ui/src/mapping/core/c8y-agent.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ export class C8YAgent {
try {
deviceId = await this.resolveExternalId2GlobalId(identity, context);
} catch (e) {
console.log(
`External id ${identity.externalId} doesn't exist! Just return original id ${identity.externalId} `
);
//console.log(
// `External id ${identity.externalId} doesn't exist! Just return original id ${identity.externalId} `
//);
}

const currentRequest =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ export class EditSubstitutionComponent implements OnInit, OnDestroy {
this.substitutionText = `[ ${marksDeviceIdentifier}${this.substitution.pathSource} -> ${this.substitution.pathTarget} ]`;
this.disabled$.next(this.duplicateSubstitution);
// console.log("Repair Options:", this.repairStrategyOptions);
console.log('Existing substitution:', this.existingSubstitution);
//console.log('Existing substitution:', this.existingSubstitution);
}

onDismiss() {
console.log('Dismiss');
//console.log('Dismiss');
this.closeSubject.next(undefined);
}

onSave() {
console.log('Save');
//console.log('Save');
this.closeSubject.next(this.editedSubstitution);
}

onOverrideChanged() {
const result = this.duplicateSubstitution && !this.override;
console.log('Override:', result);
//console.log('Override:', result);
this.disabled$.next(result);
}

Expand Down
24 changes: 12 additions & 12 deletions dynamic-mapping-ui/src/mapping/grid/mapping.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export class MappingComponent implements OnInit, OnDestroy {
initialState
});
modalRef.content.closeSubject.subscribe((result) => {
console.log('Was selected:', result);
//console.log('Was selected:', result);
if (result) {
this.mappingType = result;
this.addMapping();
Expand Down Expand Up @@ -456,7 +456,7 @@ export class MappingComponent implements OnInit, OnDestroy {
}

async deleteSubscription(device: IIdentified) {
console.log('Delete device', device);
//console.log('Delete device', device);
try {
await this.mappingService.deleteSubscriptions(device);
this.alertService.success(
Expand Down Expand Up @@ -497,7 +497,7 @@ export class MappingComponent implements OnInit, OnDestroy {
this.mappingToUpdate.direction == null
)
this.mappingToUpdate.direction = Direction.INBOUND;
console.log('Editing mapping', this.mappingToUpdate);
//console.log('Editing mapping', this.mappingToUpdate);
this.showConfigMapping = true;
}

Expand All @@ -522,7 +522,7 @@ export class MappingComponent implements OnInit, OnDestroy {
this.mappingToUpdate.ident = uuidCustom();
this.mappingToUpdate.id = this.mappingToUpdate.ident;
this.mappingToUpdate.active = false;
console.log('Copying mapping', this.mappingToUpdate);
//console.log('Copying mapping', this.mappingToUpdate);
this.showConfigMapping = true;
}

Expand Down Expand Up @@ -553,7 +553,7 @@ export class MappingComponent implements OnInit, OnDestroy {
): Promise<boolean> {
const { mapping } = m;
let result: boolean = false;
console.log('Deleting mapping before confirmation:', mapping);
//console.log('Deleting mapping before confirmation:', mapping);
if (confirmation) {
const initialState = {
title: multiple ? 'Delete mappings' : 'Delete mapping',
Expand All @@ -572,10 +572,10 @@ export class MappingComponent implements OnInit, OnDestroy {

result = await confirmDeletionModalRef.content.closeSubject.toPromise();
if (result) {
console.log('DELETE mapping:', mapping, result);
//console.log('DELETE mapping:', mapping, result);
await this.deleteMapping(m);
} else {
console.log('Canceled DELETE mapping', mapping, result);
//console.log('Canceled DELETE mapping', mapping, result);
}
} else {
// await this.deleteMapping(mapping);
Expand All @@ -598,7 +598,7 @@ export class MappingComponent implements OnInit, OnDestroy {
// test if new/updated mapping was committed or if cancel
mapping.lastUpdate = Date.now();

console.log('Changed mapping:', mapping);
//('Changed mapping:', mapping);

if (
mapping.direction == Direction.INBOUND ||
Expand All @@ -607,7 +607,7 @@ export class MappingComponent implements OnInit, OnDestroy {
// && isFilterOutboundUnique(mapping, this.mappings)
) {
if (this.stepperConfiguration.editorMode == EditorMode.UPDATE) {
console.log('Update existing mapping:', mapping);
//console.log('Update existing mapping:', mapping);
try {
await this.mappingService.updateMapping(mapping);
this.alertService.success(gettext('Mapping updated successfully'));
Expand All @@ -622,7 +622,7 @@ export class MappingComponent implements OnInit, OnDestroy {
this.stepperConfiguration.editorMode == EditorMode.COPY
) {
// new mapping
console.log('Push new mapping:', mapping);
//console.log('Push new mapping:', mapping);
try {
await this.mappingService.createMapping(mapping);
this.alertService.success(gettext('Mapping created successfully'));
Expand Down Expand Up @@ -657,7 +657,7 @@ export class MappingComponent implements OnInit, OnDestroy {
api: API.ALL.name,
devices: deviceList
};
console.log('Changed deviceList:', this.subscription.devices);
//console.log('Changed deviceList:', this.subscription.devices);
try {
await this.mappingService.updateSubscriptions(this.subscription);
this.alertService.success(gettext('Subscriptions updated successfully'));
Expand Down Expand Up @@ -764,7 +764,7 @@ export class MappingComponent implements OnInit, OnDestroy {
const response2 = await this.brokerConfigurationService.runOperation(
Operation.RELOAD_MAPPINGS
);
console.log('Activate mapping response:', response2);
//console.log('Activate mapping response:', response2);
if (response2.status < 300) {
this.alertService.success(gettext('Mappings reloaded'));
this.isConnectionToMQTTEstablished = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class MappingTypeComponent implements OnInit, OnDestroy {

ngOnInit(): void {
this.closeSubject = new Subject();
console.log('Subject:', this.closeSubject, this.labels);
//console.log('Subject:', this.closeSubject, this.labels);
this.formGroupStep = this.fb.group({
mappingType: ['', Validators.required]
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ export class JSONProcessorInbound extends PayloadProcessorInbound {
postProcessingCacheEntry
);
} else {
console.log(
`This substitution, involves an objects for: ${substitution.pathSource}, ${extractedSourceContent}`
);
//console.log(
// `This substitution, involves an objects for: ${substitution.pathSource}, ${extractedSourceContent}`
//);
context.cardinality.set(substitution.pathTarget, 1);
postProcessingCacheEntry.push({
value: extractedSourceContent,
Expand All @@ -180,9 +180,9 @@ export class JSONProcessorInbound extends PayloadProcessorInbound {
postProcessingCacheEntry
);
}
console.log(
`Evaluated substitution (pathSource:substitute)/(${substitution.pathSource}:${extractedSourceContent}), (pathTarget)/(${substitution.pathTarget})`
);
//console.log(
// `Evaluated substitution (pathSource:substitute)/(${substitution.pathSource}:${extractedSourceContent}), (pathTarget)/(${substitution.pathTarget})`
//);
}
if (substitution.pathTarget === TIME) {
substitutionTimeExists = true;
Expand Down
Loading

0 comments on commit 5a035d3

Please sign in to comment.