Search in sources :

Example 66 with Node

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project smarthome by eclipse.

the class HomieThingHandlerTests method createSpyNode.

public Node createSpyNode(String propertyID, Device device) {
    // Create the node
    Node node = spy(device.createNode("node", spy(new NodeAttributes())));
    doReturn(future).when(node.attributes).subscribeAndReceive(any(), any(), anyString(), any(), anyInt());
    doReturn(future).when(node.attributes).unsubscribe();
    node.attributes.name = "testnode";
    node.attributes.properties = new String[] { "property" };
    doAnswer(this::createSubscriberAnswer).when(node.attributes).createSubscriber(any(), any(), any(), anyBoolean());
    // Intercept creating a property in the next call and inject a spy'ed property.
    doAnswer(i -> createSpyProperty("property", node)).when(node).createProperty(any());
    return node;
}
Also used : Node(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Node) NodeAttributes(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.NodeAttributes)

Example 67 with Node

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project smarthome by eclipse.

the class ChildMapTests method testArrayToSubtopicCreateAndRemove.

@Test
public void testArrayToSubtopicCreateAndRemove() {
    AddedAction addedAction = spy(new AddedAction());
    // Assign "abc,def" to the
    subject.apply(new String[] { "abc", "def" }, addedAction, this::createNode, this::removedNode);
    assertThat(future.isDone(), is(true));
    assertThat(subject.get("abc").nodeID, is("abc"));
    assertThat(subject.get("def").nodeID, is("def"));
    verify(addedAction, times(2)).apply(any());
    Node soonToBeRemoved = subject.get("def");
    subject.apply(new String[] { "abc" }, addedAction, this::createNode, this::removedNode);
    verify(callback).nodeRemoved(eq(soonToBeRemoved));
}
Also used : Node(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Node) Test(org.junit.Test)

Example 68 with Node

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project bboxdb by jnidzwetzki.

the class OSMDataConverter method start.

/**
 * Start the converter
 */
public void start() {
    try {
        // Open file handles
        for (final OSMType osmType : filter.keySet()) {
            final BufferedWriter bw = new BufferedWriter(new FileWriter(new File(output + File.separator + osmType.toString())));
            writerMap.put(osmType, bw);
        }
        System.out.format("Importing %s%n", filename);
        final OsmosisReader reader = new OsmosisReader(new FileInputStream(filename));
        reader.setSink(new Sink() {

            @Override
            public void close() {
            }

            @Override
            public void complete() {
            }

            @Override
            public void initialize(final Map<String, Object> metaData) {
            }

            @Override
            public void process(final EntityContainer entityContainer) {
                try {
                    if (entityContainer.getEntity() instanceof Node) {
                        // Nodes are cheap to handle, dispatching to another thread
                        // is more expensive
                        final Node node = (Node) entityContainer.getEntity();
                        handleNode(node);
                        statistics.incProcessedNodes();
                    } else if (entityContainer.getEntity() instanceof Way) {
                        // Ways are expensive to handle
                        final Way way = (Way) entityContainer.getEntity();
                        queue.put(way);
                        statistics.incProcessedWays();
                    }
                } catch (InterruptedException e) {
                    return;
                }
            }
        });
        // The way consumer
        for (int i = 0; i < CONSUMER_THREADS; i++) {
            threadPool.submit(new Consumer());
        }
        reader.run();
        System.out.println("Processing of input file is complete");
        // Shutdown consumer threads
        for (int i = 0; i < CONSUMER_THREADS; i++) {
            queue.put(RED_PILL_WAY);
        }
    } catch (IOException e) {
        logger.error("Got an exception during import", e);
    } catch (InterruptedException e) {
        logger.error("Got interrupted exception", e);
        Thread.currentThread().interrupt();
    } finally {
        shutdown();
    }
}
Also used : FileWriter(java.io.FileWriter) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) SerializableNode(org.bboxdb.tools.converter.osm.util.SerializableNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) Way(org.openstreetmap.osmosis.core.domain.v0_6.Way) BufferedWriter(java.io.BufferedWriter) Sink(org.openstreetmap.osmosis.core.task.v0_6.Sink) File(java.io.File) OsmosisReader(crosby.binary.osmosis.OsmosisReader)

Example 69 with Node

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project skywalking by apache.

the class AccessLogAnalyzer method identify.

default Role identify(StreamAccessLogsMessage.Identifier alsIdentifier, Role defaultRole) {
    if (alsIdentifier == null) {
        return defaultRole;
    }
    if (!alsIdentifier.hasNode()) {
        return defaultRole;
    }
    final Node node = alsIdentifier.getNode();
    final String id = node.getId();
    if (id.startsWith("router~")) {
        return Role.PROXY;
    } else if (id.startsWith("sidecar~")) {
        return Role.SIDECAR;
    }
    return defaultRole;
}
Also used : Node(io.envoyproxy.envoy.config.core.v3.Node)

Example 70 with Node

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project geowave by locationtech.

the class OsmXmlLoader method getNodesById.

public List<Node> getNodesById(final Way way) throws IOException {
    final List<Node> wayNodes = new ArrayList<>(way.getWayNodes().size());
    for (final WayNode wn : way.getWayNodes()) {
        final Node n = getNodeById(wn);
        if (n == null) {
            throw new IOException(String.format("Error while parsing OSM XML: Node %s in Way %s (length: %s) is not declared in the document!", wn.getNodeId(), way.getId(), way.getWayNodes().size()));
        }
        wayNodes.add(n);
    }
    return wayNodes;
}
Also used : WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Aggregations

Node (org.openstreetmap.osmosis.core.domain.v0_6.Node)52 Test (org.junit.Test)27 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)26 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)21 Date (java.util.Date)18 NodeContainer (org.openstreetmap.osmosis.core.container.v0_6.NodeContainer)17 Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)16 Node (org.flyte.api.v1.Node)15 Test (org.junit.jupiter.api.Test)15 ArrayList (java.util.ArrayList)14 OsmUser (org.openstreetmap.osmosis.core.domain.v0_6.OsmUser)14 Way (org.openstreetmap.osmosis.core.domain.v0_6.Way)13 TaskNode (org.flyte.api.v1.TaskNode)10 Bound (org.openstreetmap.osmosis.core.domain.v0_6.Bound)10 List (java.util.List)9 Map (java.util.Map)9 Node (org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Node)9 Node (org.openhab.binding.mqtt.homie.internal.homie300.Node)9 EntityContainer (org.openstreetmap.osmosis.core.container.v0_6.EntityContainer)9 Node (ch.ethz.globis.phtree.v16.Node)8