0

I am reading UDP stream using java and proto buf which supports extension.

At any given time i can get three different type of data which corresponds to three different types of proto files.

I am using

            registry.add(CpuUtilization.cpuUtilExt);
            registry.add(NpuUtilization.npuExt);
            registry.add(Optics.opticsExt);

All of three proto files are using below mention syntax for extension

 extend NetworksSensors {
        optional PFEHeapInfo pfeHeapInfoExt = 1;
    }
    extend NetworksSensors {
        optional NpuUtilization npuExt = 2;
    }
    extend NetworksSensors {
        optional CpuUtilization cpuUtilExt = 3;
    }

What i am doing is create three separate methods and process the data for each type of sensor based on the value inside header field.

Is there a way i can decide which method to call based on extension data that is coming?

May be some field from descriptor can help, but i don't know to use that. Any idea?

Ammad
  • 4,031
  • 12
  • 39
  • 62

1 Answers1

0

I found a way to check whether if data have specific extension in it or not, but still have to figure it how to get Extension object from networksSensors object.

networksSensors.hasExtension(FirewallClass.firewallExt)

FirewallClass class is auto generated class using protoc compiler.

Ammad
  • 4,031
  • 12
  • 39
  • 62