Skip to content

Commit

Permalink
typos, fixed wrong serialisation of snooped msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-c8y committed Dec 29, 2024
1 parent 89cca43 commit bfd727b
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public List<ProcessingContext<?>> call() throws Exception {
mappingStatus.messagesReceived++;
if (mapping.snoopStatus == SnoopStatus.ENABLED
|| mapping.snoopStatus == SnoopStatus.STARTED) {
String serializedPayload = context.getPayloadAsString();
String serializedPayload = objectMapper.writeValueAsString(context.getPayload());
if (serializedPayload != null) {
mapping.addSnoopedTemplate(serializedPayload);
mappingStatus.snoopedTemplatesTotal = mapping.snoopedTemplates.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import static dynamic.mapping.model.MappingSubstitution.toPrettyJsonString;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,45 +227,23 @@ public List<ProcessingContext<?>> call() throws Exception {
context.getTopic(), connectorClient.getConnectorIdent(), sendPayload);
}
mappingStatus.messagesReceived++;
if (mapping.snoopStatus == SnoopStatus.ENABLED
|| mapping.snoopStatus == SnoopStatus.STARTED) {
String serializedPayload = context.getPayloadAsString();
if (serializedPayload != null) {
mapping.addSnoopedTemplate(serializedPayload);
mappingStatus.snoopedTemplatesTotal = mapping.snoopedTemplates.size();
mappingStatus.snoopedTemplatesActive++;

log.debug("Tenant {} - Adding snoopedTemplate to map: {},{},{}", tenant,
mapping.mappingTopic,
mapping.snoopedTemplates.size(),
mapping.snoopStatus);
mappingStatusComponent.addDirtyMapping(tenant, mapping);

} else {
log.warn(
"Tenant {} - Message could NOT be parsed, ignoring this message, as class is not valid: {}",
tenant,
context.getPayload().getClass());
}
} else {
processor.enrichPayload(context);
processor.extractFromSource(context);
processor.substituteInTargetAndSend(context);
Counter.builder("dynmapper_outbound_message_total")
.tag("tenant", c8yMessage.getTenant())
.description("Total number of outbound messages")
.tag("connector", processor.connectorClient.getConnectorIdent())
.register(Metrics.globalRegistry).increment();
timer.stop(Timer.builder("dynmapper_outbound_processing_time")
.tag("tenant", c8yMessage.getTenant())
.tag("connector", processor.connectorClient.getConnectorIdent())
.description("Processing time of outbound messages")
.register(Metrics.globalRegistry));

List<C8YRequest> resultRequests = context.getRequests();
if (context.hasError() || resultRequests.stream().anyMatch(r -> r.hasError())) {
mappingStatus.errors++;
}
processor.enrichPayload(context);
processor.extractFromSource(context);
processor.substituteInTargetAndSend(context);
Counter.builder("dynmapper_outbound_message_total")
.tag("tenant", c8yMessage.getTenant())
.description("Total number of outbound messages")
.tag("connector", processor.connectorClient.getConnectorIdent())
.register(Metrics.globalRegistry).increment();
timer.stop(Timer.builder("dynmapper_outbound_processing_time")
.tag("tenant", c8yMessage.getTenant())
.tag("connector", processor.connectorClient.getConnectorIdent())
.description("Processing time of outbound messages")
.register(Metrics.globalRegistry));

List<C8YRequest> resultRequests = context.getRequests();
if (context.hasError() || resultRequests.stream().anyMatch(r -> r.hasError())) {
mappingStatus.errors++;
}
processingResult.add(context);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,4 @@
# C8Y.bootstrap.user=servicebootstrap_dynamic-mapping-service
# C8Y.bootstrap.password=<BOOTSTRAP_PASSWORD>
# C8Y.bootstrap.tenant=<TENANT_ID>
# C8Y.baseURL=<TENANT_URL>

APP.additionalSubscriptionIdTest=D552
C8Y.bootstrap.user=servicebootstrap_dynamic-mapping-service
C8Y.bootstrap.password=TzW0bM69BeqybU4QeIb7SqlPCkO55562
C8Y.bootstrap.tenant=t2050305588
C8Y.baseURL=https://ck4.eu-latest.cumulocity.com
C8Y.microservice.isolation=MULTI_TENANT
# C8Y.baseURL=<TENANT_URL>
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export class FacadeInventoryService {
return this.inventory.create(managedObject);
} else {
// We force the creation of a device with a given id.
// This is required to keep the source.id and deviceId consistant, across request.
// E.g. an alarm with a c8ySourceId = '102030' is tested in teh UI, then we need
// This is required to keep the source.id and deviceId consistent, across request.
// E.g. an alarm with a c8ySourceId = '102030' is tested in the UI, then we need
// to create a device with that given id = '102030'
managedObject.id = context.sourceId;
return this.mockInventory.create(managedObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export class MockInventoryService {
managedObject: Partial<IManagedObject>
): Promise<IResult<IManagedObject>> {
// We force the creation of a device with a given id.
// This is required to keep the source.id and deviceId consistant, across request.
// E.g. an alarm with a c8ySourceId = '102030' is tested in teh UI, then we need
// This is required to keep the source.id and deviceId consistent, across request.
// E.g. an alarm with a c8ySourceId = '102030' is tested in the UI, then we need
// to create a device with that given id = '102030'
const id = managedObject.id ? managedObject.id : randomIdAsString();
const copyManagedObject = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ <h4 class="text-medium">
<div [formGroup]="templateForm">
<div class="row" #editorsTemplate>
<div class="col-lg-5 col-lg-offset-1 column-right-border" #leftTemplateTemplate>
<div class="form-group">
<div class="form-group m-b-0">
<div class="d-flex j-c-between">
<label translate>Source Template - {{ sourceSystem }}</label>
</div>
Expand All @@ -199,9 +199,6 @@ <h4 class="text-medium">
(pathChanged)="onSelectedPathSourceChanged($event)"
(initialized)="onEditorSourceInitialized()" [data]="sourceTemplate"
#editorSourceStepSubstitution></d11r-mapping-json-editor2>
<span class="text-info text-12 p-l-8">{{substitutionModel.pathSource === '' ?'Select source
node to define substitution!':'Selected source node: ' +
substitutionModel.pathSource }}</span>
</div>
<ng-container *ngIf="stepperConfiguration.showProcessorExtensionsSource">
<ng-container *ngTemplateOutlet="extensionTemplateSource; context: { form: templateForm }">
Expand All @@ -215,7 +212,7 @@ <h4 class="text-medium">
</div>
</div>
<div class="col-lg-5 column-left-border" #rightTemplateTemplate>
<div class="form-group">
<div class="form-group m-b-0">
<div class="d-flex j-c-between">
<div class="d-flex">
<label>Target Template - {{ targetSystem }}</label>
Expand All @@ -236,10 +233,25 @@ <h4 class="text-medium">
(pathChanged)="onSelectedPathTargetChanged($event)" (initialized)="onEditorTargetInitialized()"
[data]="targetTemplate" #editorTargetStepSubstitution>
</d11r-mapping-json-editor2>
</div>
</div>
</div>
<div class="row" #messages>
<div class="col-lg-5 col-lg-offset-1" #leftTemplateTemplate>
<div class="form-group m-b-8">
<div *ngIf="stepperConfiguration.showEditorSource">
<span class="text-info text-12 p-l-8">{{substitutionModel.pathSource === '' ?'Select source
node to define substitution!':'Selected source node: ' +
substitutionModel.pathSource }}</span>
</div>
</div>
</div>
<div class="col-lg-5" #rightTemplateTemplate>
<div class="form-group m-b-8">
<span class="text-info text-12 p-l-8">{{substitutionModel.pathTarget === '' &&
stepperConfiguration.showEditorSource ?'Select target
node to define substitution!':'Selected source node: ' +
substitutionModel.pathSource }}</span>
node to define substitution!':'Selected target node: ' +
substitutionModel.pathTarget }}</span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,17 @@ import {
Direction,
Extension,
ExtensionEntry,
getExternalTemplate,
getSchema,
JsonEditorComponent,
Mapping,
MappingSubstitution,
RepairStrategy,
SAMPLE_TEMPLATES_C8Y,
SnoopStatus,
StepperConfiguration,
getExternalTemplate,
getSchema,
} from '../../shared';
import { JsonEditorComponent } from '../../shared';
import { countDeviceIdentifiers, getGenericDeviceIdentifier } from '../../shared/mapping/mapping.model';
import { MappingService } from '../core/mapping.service';
import { ValidationError } from '../shared/mapping.model';
import { EditorMode, STEP_DEFINE_SUBSTITUTIONS, STEP_GENERAL_SETTINGS, STEP_SELECT_TEMPLATES, STEP_TEST_MAPPING } from '../shared/stepper.model';
Expand All @@ -67,7 +68,6 @@ import {
reduceSourceTemplate,
splitTopicExcludingSeparator
} from '../shared/util';
import { countDeviceIdentifiers, getGenericDeviceIdentifier } from '../../shared/mapping/mapping.model';
import { EditSubstitutionComponent } from '../substitution/edit/edit-substitution-modal.component';
import { SubstitutionRendererComponent } from '../substitution/substitution-grid.component';

Expand Down

0 comments on commit bfd727b

Please sign in to comment.