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;
}
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));
}
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();
}
}
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;
}
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;
}
Aggregations