Search in sources :

Example 1 with Option

use of org.knime.node.v41.Option in project eblocker by eblocker.

the class NeighborDiscoveryListener method parseNeighborSolicitation.

private NeighborSolicitation parseNeighborSolicitation(MessageReader reader, byte[] sourceHardwareAddress, Ip6Address sourceAddress, byte[] destinationHardwareAddress, Ip6Address destinationAddress) throws MessageException {
    Ip6Address targetAddress = reader.nextIp6Address();
    List<Option> options = parseOptions(reader);
    return new NeighborSolicitation(sourceHardwareAddress, sourceAddress, destinationHardwareAddress, destinationAddress, targetAddress, options);
}
Also used : Ip6Address(org.eblocker.server.common.data.Ip6Address) NeighborSolicitation(org.eblocker.server.common.network.icmpv6.NeighborSolicitation) RecursiveDnsServerOption(org.eblocker.server.common.network.icmpv6.RecursiveDnsServerOption) TargetLinkLayerAddressOption(org.eblocker.server.common.network.icmpv6.TargetLinkLayerAddressOption) PrefixOption(org.eblocker.server.common.network.icmpv6.PrefixOption) Option(org.eblocker.server.common.network.icmpv6.Option) MtuOption(org.eblocker.server.common.network.icmpv6.MtuOption) SourceLinkLayerAddressOption(org.eblocker.server.common.network.icmpv6.SourceLinkLayerAddressOption) LinkLayerAddressOption(org.eblocker.server.common.network.icmpv6.LinkLayerAddressOption)

Example 2 with Option

use of org.knime.node.v41.Option in project eblocker by eblocker.

the class NeighborDiscoveryListener method parseNeighborAdvertisement.

private NeighborAdvertisement parseNeighborAdvertisement(MessageReader reader, byte[] sourceHardwareAddress, Ip6Address sourceAddress, byte[] destinationHardwareAddress, Ip6Address destinationAddress) throws MessageException {
    boolean router = reader.nextBoolean();
    boolean solicited = reader.nextBoolean();
    boolean override = reader.nextBoolean();
    Ip6Address targetAddress = reader.nextIp6Address();
    List<Option> options = parseOptions(reader);
    return new NeighborAdvertisement(sourceHardwareAddress, sourceAddress, destinationHardwareAddress, destinationAddress, router, solicited, override, targetAddress, options);
}
Also used : Ip6Address(org.eblocker.server.common.data.Ip6Address) NeighborAdvertisement(org.eblocker.server.common.network.icmpv6.NeighborAdvertisement) RecursiveDnsServerOption(org.eblocker.server.common.network.icmpv6.RecursiveDnsServerOption) TargetLinkLayerAddressOption(org.eblocker.server.common.network.icmpv6.TargetLinkLayerAddressOption) PrefixOption(org.eblocker.server.common.network.icmpv6.PrefixOption) Option(org.eblocker.server.common.network.icmpv6.Option) MtuOption(org.eblocker.server.common.network.icmpv6.MtuOption) SourceLinkLayerAddressOption(org.eblocker.server.common.network.icmpv6.SourceLinkLayerAddressOption) LinkLayerAddressOption(org.eblocker.server.common.network.icmpv6.LinkLayerAddressOption)

Example 3 with Option

use of org.knime.node.v41.Option in project jackrabbit-filevault by apache.

the class CliHelpFormatter method printHelp.

/**
 * Prints detailed help per option.
 */
public void printHelp() {
    printDivider();
    printDescription();
    final Option option;
    final PrintWriter out = getPrintWriter();
    if ((getException() != null) && (getException().getOption() != null)) {
        option = getException().getOption();
    } else if (cmd != null) {
        option = cmd.getCommand();
    } else {
        option = getGroup();
    }
    // grab the HelpLines to display
    final List helpLines = option.helpLines(skipToplevel ? -1 : 0, getDisplaySettings(), getComparator());
    if (skipToplevel) {
        helpLines.remove(0);
    }
    // calculate the maximum width of the usage strings
    int usageWidth = 0;
    for (final Iterator i = helpLines.iterator(); i.hasNext(); ) {
        final HelpLine helpLine = (HelpLine) i.next();
        final String usage = helpLine.usage(getLineUsageSettings(), getComparator());
        usageWidth = Math.max(usageWidth, usage.length());
    }
    // build a blank string to pad wrapped descriptions
    final StringBuffer blankBuffer = new StringBuffer();
    for (int i = 0; i < usageWidth; i++) {
        blankBuffer.append(' ');
    }
    // print a blank line
    out.println();
    // determine the width available for descriptions
    final int descriptionWidth = Math.max(1, getPageWidth() - getGutterCenter().length() - usageWidth);
    // display each HelpLine
    for (final Iterator i = helpLines.iterator(); i.hasNext(); ) {
        // grab the HelpLine
        final HelpLine helpLine = (HelpLine) i.next();
        // wrap the description
        final List descList = wrap(helpLine.getDescription(), descriptionWidth);
        final Iterator descriptionIterator = descList.iterator();
        // display usage + first line of description
        printGutterLeft();
        pad(helpLine.usage(getLineUsageSettings(), getComparator()), usageWidth, out);
        out.print(getGutterCenter());
        pad((String) descriptionIterator.next(), descriptionWidth, out);
        printGutterRight();
        out.println();
        // display padding + remaining lines of description
        while (descriptionIterator.hasNext()) {
            printGutterLeft();
            // pad(helpLine.getUsage(),usageWidth,out);
            out.print(blankBuffer);
            out.print(getGutterCenter());
            pad((String) descriptionIterator.next(), descriptionWidth, out);
            printGutterRight();
            out.println();
        }
    }
    printExample();
    printDivider();
}
Also used : HelpLine(org.apache.commons.cli2.HelpLine) Iterator(java.util.Iterator) Option(org.apache.commons.cli2.Option) List(java.util.List) PrintWriter(java.io.PrintWriter)

Example 4 with Option

use of org.knime.node.v41.Option in project disco-to-proto3-converter by googleapis.

the class ServiceConfigWriter method writeToFile.

@Override
public void writeToFile(PrintWriter writer, ProtoFile protoFile, boolean outputComments) throws IOException {
    ServiceConfig serviceConfig = new ServiceConfig();
    String protoPkg = protoFile.getMetadata().getProtoPkg();
    RetryPolicy idempotentRetryPolicy = new RetryPolicy("0.100s", "60s", 1.3D, Arrays.asList("DEADLINE_EXCEEDED", "UNAVAILABLE"));
    MethodConfig idempotentMethodConfig = new MethodConfig("600s", idempotentRetryPolicy);
    MethodConfig nonidempotentMethodConfig = new MethodConfig("600s", null);
    for (GrpcService service : protoFile.getServices().values()) {
        for (GrpcMethod method : service.getMethods()) {
            Optional<Option> opt = method.getOptions().stream().filter(o -> o.getName().equals("google.api.http")).findFirst();
            Name name = new Name(protoPkg + "." + service.getName(), method.getName());
            if (opt.isPresent() && opt.get().getProperties().containsKey("get")) {
                idempotentMethodConfig.getName().add(name);
            } else {
                nonidempotentMethodConfig.getName().add(name);
            }
        }
    }
    serviceConfig.getMethodConfig().add(idempotentMethodConfig);
    serviceConfig.getMethodConfig().add(nonidempotentMethodConfig);
    ObjectMapper mapper = new ObjectMapper();
    String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(serviceConfig);
    writer.println(json);
}
Also used : MethodConfig(com.google.cloud.discotoproto3converter.serviceconfig.ServiceConfig.MethodConfig) GrpcMethod(com.google.cloud.discotoproto3converter.proto3.GrpcMethod) PrintWriter(java.io.PrintWriter) RetryPolicy(com.google.cloud.discotoproto3converter.serviceconfig.ServiceConfig.RetryPolicy) ConverterWriter(com.google.cloud.discotoproto3converter.proto3.ConverterWriter) Arrays(java.util.Arrays) Name(com.google.cloud.discotoproto3converter.serviceconfig.ServiceConfig.Name) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) GrpcMethod(com.google.cloud.discotoproto3converter.proto3.GrpcMethod) IOException(java.io.IOException) GrpcService(com.google.cloud.discotoproto3converter.proto3.GrpcService) MethodConfig(com.google.cloud.discotoproto3converter.serviceconfig.ServiceConfig.MethodConfig) Optional(java.util.Optional) Option(com.google.cloud.discotoproto3converter.proto3.Option) ProtoFile(com.google.cloud.discotoproto3converter.proto3.ProtoFile) GrpcService(com.google.cloud.discotoproto3converter.proto3.GrpcService) Option(com.google.cloud.discotoproto3converter.proto3.Option) RetryPolicy(com.google.cloud.discotoproto3converter.serviceconfig.ServiceConfig.RetryPolicy) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Name(com.google.cloud.discotoproto3converter.serviceconfig.ServiceConfig.Name)

Example 5 with Option

use of org.knime.node.v41.Option in project disco-to-proto3-converter by googleapis.

the class GapicYamlWriter method writeToFile.

@Override
public void writeToFile(PrintWriter writer, ProtoFile protoFile, boolean outputComments) {
    writeLicenseAndWarning(writer, protoFile.getMetadata());
    writer.println("type: com.google.api.codegen.ConfigProto");
    writer.println("config_schema_version: 2.0.0");
    writer.println("language_settings:");
    // Consider adding other languages as well, if ever needed
    writer.println("  java:");
    writer.println("    package_name: com." + protoFile.getMetadata().getProtoPkg());
    writer.println("interfaces:");
    for (GrpcService service : protoFile.getServices().values()) {
        boolean firstMethod = true;
        for (GrpcMethod method : service.getMethods()) {
            Optional<Option> opt = method.getOptions().stream().filter(o -> o.getName().equals("google.cloud.operation_service")).findFirst();
            if (!opt.isPresent()) {
                continue;
            }
            if (firstMethod) {
                writer.println("- name: " + protoFile.getMetadata().getProtoPkg() + "." + service.getName());
                writer.println("  methods:");
                firstMethod = false;
            }
            writer.println("  - name: " + method.getName());
            // Consider making these configurable
            writer.println("    long_running:");
            writer.println("      initial_poll_delay_millis: 500");
            writer.println("      poll_delay_multiplier: 1.5");
            writer.println("      max_poll_delay_millis: 20000");
            writer.println("      total_poll_timeout_millis: 600000");
        }
    }
}
Also used : GrpcMethod(com.google.cloud.discotoproto3converter.proto3.GrpcMethod) PrintWriter(java.io.PrintWriter) ConverterWriter(com.google.cloud.discotoproto3converter.proto3.ConverterWriter) GrpcService(com.google.cloud.discotoproto3converter.proto3.GrpcService) Optional(java.util.Optional) GrpcMethod(com.google.cloud.discotoproto3converter.proto3.GrpcMethod) Option(com.google.cloud.discotoproto3converter.proto3.Option) ProtoFileMetadata(com.google.cloud.discotoproto3converter.proto3.ProtoFileMetadata) ProtoFile(com.google.cloud.discotoproto3converter.proto3.ProtoFile) GrpcService(com.google.cloud.discotoproto3converter.proto3.GrpcService) Option(com.google.cloud.discotoproto3converter.proto3.Option)

Aggregations

Ip6Address (org.eblocker.server.common.data.Ip6Address)4 Option (org.eblocker.server.common.network.icmpv6.Option)4 SourceLinkLayerAddressOption (org.eblocker.server.common.network.icmpv6.SourceLinkLayerAddressOption)4 PrintWriter (java.io.PrintWriter)3 Option (org.apache.commons.cli2.Option)3 LinkLayerAddressOption (org.eblocker.server.common.network.icmpv6.LinkLayerAddressOption)3 MtuOption (org.eblocker.server.common.network.icmpv6.MtuOption)3 PrefixOption (org.eblocker.server.common.network.icmpv6.PrefixOption)3 RecursiveDnsServerOption (org.eblocker.server.common.network.icmpv6.RecursiveDnsServerOption)3 TargetLinkLayerAddressOption (org.eblocker.server.common.network.icmpv6.TargetLinkLayerAddressOption)3 ConverterWriter (com.google.cloud.discotoproto3converter.proto3.ConverterWriter)2 GrpcMethod (com.google.cloud.discotoproto3converter.proto3.GrpcMethod)2 GrpcService (com.google.cloud.discotoproto3converter.proto3.GrpcService)2 Option (com.google.cloud.discotoproto3converter.proto3.Option)2 ProtoFile (com.google.cloud.discotoproto3converter.proto3.ProtoFile)2 List (java.util.List)2 Optional (java.util.Optional)2 CommandLine (org.apache.commons.cli2.CommandLine)2 Group (org.apache.commons.cli2.Group)2 ArgumentBuilder (org.apache.commons.cli2.builder.ArgumentBuilder)2