highstreet-technologies / transportpce Goto Github PK
View Code? Open in Web Editor NEWThis project forked from opendaylight/transportpce
Mirror of the OpenDaylight transportpce gerrit project
This project forked from opendaylight/transportpce
Mirror of the OpenDaylight transportpce gerrit project
With additional import of odl OSGi-Service
<reference id="parserFactory" interface="org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory" />
it should be much easier to serialize data like ODL does
import com.google.gson.stream.JsonWriter;
import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers;
import org.opendaylight.mdsal.binding.dom.codec.impl.BindingCodecContext;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.config.rev201208.Configuration;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.config.rev201208.ConfigurationBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.config.rev201208.configuration.EntryBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.config.rev201208.configuration.EntryKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.Uint8;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactory;
import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
import org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.parser.api.YangParser;
import org.opendaylight.yangtools.yang.model.parser.api.YangParserException;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl;
...
private void serialize(Configuration configuration) {
final YangParser parser = this.yangParserFactory.createParser();
final EffectiveModelContext schemaContext = parser.buildEffectiveModel();
final NormalizedNode<?, ?> data = BINDING_CONTEXT.toNormalizedNode(
InstanceIdentifier.create(Configuration.class), configuration).getValue();
final String json = toJson(data, schemaContext);
}
private static String toJson(final NormalizedNode<?, ?> node, final EffectiveModelContext schemaContext) {
final JSONCodecFactory codecFactory = JSONCodecFactorySupplier.RFC7951.createSimple(schemaContext);
try (StringWriter stringWriter = new StringWriter();
JsonWriter jsonWriter = new JsonWriter(stringWriter);
NormalizedNodeWriter nodeStreamer = NormalizedNodeWriter.forStreamWriter(
JSONNormalizedNodeStreamWriter.createNestedWriter(codecFactory, SchemaPath.ROOT,
schemaContext.getQName().getNamespace(), jsonWriter))) {
jsonWriter.beginObject();
nodeStreamer.write(node);
jsonWriter.endObject();
return stringWriter.toString();
} catch (IOException e) {
throw new IllegalStateException("Failed to convert input node to JSON: " + node, e);
}
}
Task is to replace our internal yangtools independent serializer with this one, to solve not covered bugs in the existing serializer
Analysis:
In the container the sdnr-wt related bundles are missing.
The related devicemanager can not start.
Proposed solution:
move odl-client and odl-ready bundles to another repo to keep it independent from transportPCE and so also available for other projects
Add a globals class which can be included by all transportpce subprojects (at least those with manual delays) and define these delay values there and so replace them with the variable values.
They should be the same as before, but overridable by env var
Maybe transportpce/common is the best location for this
Example
package org.opendaylight.transportpce.common;
public class Globals {
public static int SLEEP_10000 = getEnvOrDefault(SLEEP_10000,10000);
}
private static int getEnvOrDefault(String envVar, int def) {
...
}
to find all sleep commands in the transportpce code
grep "Thread.sleep(" $(find -name *.java) | grep -v target
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.