use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project voltdb by VoltDB.
the class VoltDBOsmSink method process.
public void process(NodeContainer nodeContainer) {
Node node;
node = nodeContainer.getEntity();
double lat = node.getLatitude();
double lng = node.getLongitude();
String pointText = "POINT(" + lng + " " + lat + ")";
// keep track of the nodes so we can build polygons later
if (enableBboxBuilder || enableLinestringBuilder) {
wayGeometryBuilder.addNodeLocation(node);
}
try {
client.callProcedure(new InsertCallback(), INS_NODE_PROC, node.getId(), node.getVersion(), node.getUser().getId(), new TimestampType(node.getTimestamp().getTime()), node.getChangesetId(), pointText);
} catch (NoConnectionsException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Collection<Tag> tags = node.getTags();
for (Tag tag : tags) {
// System.out.println(INS_NODE_TAG_PROC+","+node.getId()+","+tag.getKey()+","+tag.getValue());
try {
client.callProcedure(new InsertCallback(), INS_NODE_TAG_PROC, node.getId(), tag.getKey(), tag.getValue());
} catch (NoConnectionsException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project GeoGig by boundlessgeo.
the class OSMExport method getFeatures.
private Iterator<EntityContainer> getFeatures(String ref) {
Optional<ObjectId> id = geogig.command(RevParse.class).setRefSpec(ref).call();
if (!id.isPresent()) {
return Iterators.emptyIterator();
}
LsTreeOp op = geogig.command(LsTreeOp.class).setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).setReference(ref);
if (bbox != null) {
final Envelope env;
try {
env = new Envelope(Double.parseDouble(bbox.get(0)), Double.parseDouble(bbox.get(2)), Double.parseDouble(bbox.get(1)), Double.parseDouble(bbox.get(3)));
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Wrong bbox definition");
}
Predicate<Bounded> filter = new Predicate<Bounded>() {
@Override
public boolean apply(final Bounded bounded) {
boolean intersects = bounded.intersects(env);
return intersects;
}
};
op.setBoundsFilter(filter);
}
Iterator<NodeRef> iterator = op.call();
final EntityConverter converter = new EntityConverter();
Function<NodeRef, EntityContainer> function = new Function<NodeRef, EntityContainer>() {
@Override
@Nullable
public EntityContainer apply(@Nullable NodeRef ref) {
RevFeature revFeature = geogig.command(RevObjectParse.class).setObjectId(ref.objectId()).call(RevFeature.class).get();
SimpleFeatureType featureType;
if (ref.path().startsWith(OSMUtils.NODE_TYPE_NAME)) {
featureType = OSMUtils.nodeType();
} else {
featureType = OSMUtils.wayType();
}
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType);
RevFeatureType revFeatureType = RevFeatureTypeImpl.build(featureType);
List<PropertyDescriptor> descriptors = revFeatureType.sortedDescriptors();
ImmutableList<Optional<Object>> values = revFeature.getValues();
for (int i = 0; i < descriptors.size(); i++) {
PropertyDescriptor descriptor = descriptors.get(i);
Optional<Object> value = values.get(i);
featureBuilder.set(descriptor.getName(), value.orNull());
}
SimpleFeature feature = featureBuilder.buildFeature(ref.name());
Entity entity = converter.toEntity(feature, null);
EntityContainer container;
if (entity instanceof Node) {
container = new NodeContainer((Node) entity);
} else {
container = new WayContainer((Way) entity);
}
return container;
}
};
return Iterators.transform(iterator, function);
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project instrumentation-java by census-instrumentation.
the class OcAgentMetricsExporterIntegrationTest method testExportMetrics.
@Test
public void testExportMetrics() throws InterruptedException, IOException {
// Mock a real-life scenario in production, where Agent is not enabled at first, then enabled
// after an outage. Users should be able to see metrics shortly after Agent is up.
registerAllViews();
LongGauge gauge = registerGauge();
// Register the OcAgent Exporter first.
// Agent is not yet up and running so Exporter will just retry connection.
OcAgentMetricsExporter.createAndRegister(OcAgentMetricsExporterConfiguration.builder().setServiceName(SERVICE_NAME).setUseInsecure(true).setRetryInterval(RETRY_INTERVAL).setExportInterval(EXPORT_INTERVAL).build());
doWork(5, gauge.getOrCreateTimeSeries(Collections.singletonList(LabelValue.create("First work"))));
// Wait 3s so that all metrics get exported.
Thread.sleep(3000);
// No interaction with Agent so far.
assertThat(fakeOcAgentMetricsServiceGrpc.getExportMetricsServiceRequests()).isEmpty();
// Imagine that an outage happened, now start Agent. Exporter should be able to connect to Agent
// after the next retry interval.
agent.start();
// Wait 3s for Exporter to start another attempt to connect to Agent.
Thread.sleep(3000);
doWork(8, gauge.getOrCreateTimeSeries(Collections.singletonList(LabelValue.create("Second work"))));
// Wait 3s so that all metrics get exported.
Thread.sleep(3000);
List<ExportMetricsServiceRequest> exportRequests = fakeOcAgentMetricsServiceGrpc.getExportMetricsServiceRequests();
assertThat(exportRequests.size()).isAtLeast(2);
ExportMetricsServiceRequest firstRequest = exportRequests.get(0);
Node expectedNode = OcAgentNodeUtils.getNodeInfo(SERVICE_NAME);
Node actualNode = firstRequest.getNode();
assertThat(actualNode.getIdentifier().getHostName()).isEqualTo(expectedNode.getIdentifier().getHostName());
assertThat(actualNode.getIdentifier().getPid()).isEqualTo(expectedNode.getIdentifier().getPid());
assertThat(actualNode.getLibraryInfo()).isEqualTo(expectedNode.getLibraryInfo());
assertThat(actualNode.getServiceInfo()).isEqualTo(expectedNode.getServiceInfo());
List<Metric> metricProtos = new ArrayList<>();
for (int i = 1; i < exportRequests.size(); i++) {
metricProtos.addAll(exportRequests.get(i).getMetricsList());
}
// There should be at least one metric exported for each view and gauge (4 + 1).
assertThat(metricProtos.size()).isAtLeast(5);
Set<String> expectedMetrics = new HashSet<>();
expectedMetrics.add("jobs");
for (View view : VIEWS) {
expectedMetrics.add(view.getName().asString());
}
Set<String> actualMetrics = new HashSet<>();
for (Metric metricProto : metricProtos) {
actualMetrics.add(metricProto.getMetricDescriptor().getName());
}
assertThat(actualMetrics).containsAtLeastElementsIn(expectedMetrics);
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project instrumentation-java by census-instrumentation.
the class OcAgentTraceExporterIntegrationTest method testExportSpans.
@Test
public void testExportSpans() throws InterruptedException, IOException {
// Mock a real-life scenario in production, where Agent is not enabled at first, then enabled
// after an outage. Users should be able to see traces shortly after Agent is up.
// Configure to be always-sampled.
TraceConfig traceConfig = Tracing.getTraceConfig();
TraceParams activeTraceParams = traceConfig.getActiveTraceParams();
traceConfig.updateActiveTraceParams(activeTraceParams.toBuilder().setSampler(Samplers.alwaysSample()).build());
// Register the OcAgent Exporter first.
// Agent is not yet up and running so Exporter will just retry connection.
OcAgentTraceExporter.createAndRegister(OcAgentTraceExporterConfiguration.builder().setServiceName(SERVICE_NAME).setUseInsecure(true).setEnableConfig(false).build());
// Create one root span and 5 children.
try (Scope scope = tracer.spanBuilder("root").startScopedSpan()) {
for (int i = 0; i < 5; i++) {
// Fake work
doWork("first-iteration-child-" + i, i);
}
}
// Wait 5s so that SpanExporter exports exports all spans.
Thread.sleep(5000);
// No interaction with Agent so far.
assertThat(fakeOcAgentTraceServiceGrpc.getExportTraceServiceRequests()).isEmpty();
// Image an outage happened, now start Agent. Exporter should be able to connect to Agent
// when the next batch of SpanData arrives.
agent.start();
// Create one root span and 8 children.
try (Scope scope = tracer.spanBuilder("root2").startScopedSpan()) {
for (int i = 0; i < 8; i++) {
// Fake work
doWork("second-iteration-child-" + i, i);
}
}
// Wait 5s so that SpanExporter exports exports all spans.
Thread.sleep(5000);
List<ExportTraceServiceRequest> exportRequests = fakeOcAgentTraceServiceGrpc.getExportTraceServiceRequests();
assertThat(exportRequests.size()).isAtLeast(2);
ExportTraceServiceRequest firstRequest = exportRequests.get(0);
Node expectedNode = OcAgentNodeUtils.getNodeInfo(SERVICE_NAME);
Node actualNode = firstRequest.getNode();
assertThat(actualNode.getIdentifier().getHostName()).isEqualTo(expectedNode.getIdentifier().getHostName());
assertThat(actualNode.getIdentifier().getPid()).isEqualTo(expectedNode.getIdentifier().getPid());
assertThat(actualNode.getLibraryInfo()).isEqualTo(expectedNode.getLibraryInfo());
assertThat(actualNode.getServiceInfo()).isEqualTo(expectedNode.getServiceInfo());
List<io.opencensus.proto.trace.v1.Span> spanProtos = new ArrayList<>();
for (int i = 1; i < exportRequests.size(); i++) {
spanProtos.addAll(exportRequests.get(i).getSpansList());
}
// On some platforms (e.g Windows) SpanData will never be dropped, so spans from the first batch
// may also be exported after Agent is up.
assertThat(spanProtos.size()).isAtLeast(9);
Set<String> exportedSpanNames = new HashSet<>();
for (io.opencensus.proto.trace.v1.Span spanProto : spanProtos) {
if ("root2".equals(spanProto.getName().getValue())) {
assertThat(spanProto.getChildSpanCount().getValue()).isEqualTo(8);
assertThat(spanProto.getParentSpanId()).isEqualTo(ByteString.EMPTY);
} else if ("root".equals(spanProto.getName().getValue())) {
// This won't happen on Linux but does happen on Windows.
assertThat(spanProto.getChildSpanCount().getValue()).isEqualTo(5);
assertThat(spanProto.getParentSpanId()).isEqualTo(ByteString.EMPTY);
}
exportedSpanNames.add(spanProto.getName().getValue());
}
// The second batch of spans should be exported no matter what.
assertThat(exportedSpanNames).contains("root2");
for (int i = 0; i < 8; i++) {
assertThat(exportedSpanNames).contains("second-iteration-child-" + i);
}
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project grpc-java by grpc.
the class CsdsServiceTest method verifyClientConfigNode.
/**
* Assuming {@link io.grpc.xds.EnvoyProtoDataTest#convertNode} passes, perform a minimal check,
* just verify the node itself is the one we expect.
*/
private static void verifyClientConfigNode(ClientConfig clientConfig) {
Node node = clientConfig.getNode();
assertThat(node.getId()).isEqualTo(NODE_ID);
assertThat(node).isEqualTo(BOOTSTRAP_NODE.toEnvoyProtoNode());
}
Aggregations