Class WorkerUtils


  • public final class WorkerUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.apache.pulsar.client.api.Producer<byte[]> createExclusiveProducerWithRetry​(org.apache.pulsar.client.api.PulsarClient client, java.lang.String topic, java.lang.String producerName, java.util.function.Supplier<java.lang.Boolean> isLeader, int sleepInBetweenMs)  
      static org.apache.pulsar.client.api.Reader<byte[]> createReader​(org.apache.pulsar.client.api.ReaderBuilder readerBuilder, java.lang.String readerName, java.lang.String topic, org.apache.pulsar.client.api.MessageId startMessageId)  
      static void deleteFromBookkeeper​(org.apache.distributedlog.api.namespace.Namespace namespace, java.lang.String packagePath)  
      static void downloadFromBookkeeper​(org.apache.distributedlog.api.namespace.Namespace namespace, java.io.File outputFile, java.lang.String packagePath)  
      static void downloadFromBookkeeper​(org.apache.distributedlog.api.namespace.Namespace namespace, java.io.OutputStream outputStream, java.lang.String packagePath)  
      static java.io.File dumpToTmpFile​(java.io.InputStream uploadedInputStream)  
      static org.apache.distributedlog.DistributedLogConfiguration getDlogConf​(org.apache.pulsar.functions.worker.WorkerConfig workerConfig)  
      static org.apache.pulsar.common.policies.data.FunctionInstanceStatsImpl getFunctionInstanceStats​(java.lang.String fullyQualifiedInstanceName, FunctionRuntimeInfo functionRuntimeInfo, int instanceId)  
      static java.util.function.Supplier<java.lang.Boolean> getIsStillLeaderSupplier​(MembershipManager membershipManager, java.lang.String workerId)  
      static org.apache.pulsar.client.admin.PulsarAdmin getPulsarAdminClient​(java.lang.String pulsarWebServiceUrl)  
      static org.apache.pulsar.client.admin.PulsarAdmin getPulsarAdminClient​(java.lang.String pulsarWebServiceUrl, java.lang.String authPlugin, java.lang.String authParams, java.lang.String tlsTrustCertsFilePath, java.lang.Boolean allowTlsInsecureConnection, java.lang.Boolean enableTlsHostnameVerificationEnable)  
      static org.apache.pulsar.client.admin.PulsarAdmin getPulsarAdminClient​(java.lang.String pulsarWebServiceUrl, java.lang.String authPlugin, java.lang.String authParams, java.lang.String tlsTrustCertsFilePath, java.lang.Boolean allowTlsInsecureConnection, java.lang.Boolean enableTlsHostnameVerificationEnable, org.apache.pulsar.functions.worker.WorkerConfig workerConfig)  
      static org.apache.pulsar.client.api.PulsarClient getPulsarClient​(java.lang.String pulsarServiceUrl)  
      static org.apache.pulsar.client.api.PulsarClient getPulsarClient​(java.lang.String pulsarServiceUrl, java.lang.String authPlugin, java.lang.String authParams, java.lang.Boolean useTls, java.lang.String tlsTrustCertsFilePath, java.lang.Boolean allowTlsInsecureConnection, java.lang.Boolean enableTlsHostnameVerificationEnable)  
      static org.apache.pulsar.client.api.PulsarClient getPulsarClient​(java.lang.String pulsarServiceUrl, java.lang.String authPlugin, java.lang.String authParams, java.lang.Boolean useTls, java.lang.String tlsTrustCertsFilePath, java.lang.Boolean allowTlsInsecureConnection, java.lang.Boolean enableTlsHostnameVerificationEnable, org.apache.pulsar.functions.worker.WorkerConfig workerConfig)  
      static java.net.URI initializeDlogNamespace​(org.apache.pulsar.common.conf.InternalConfigurationData internalConf)  
      static java.net.URI newDlogNamespaceURI​(java.lang.String zookeeperServers)  
      static void uploadFileToBookkeeper​(java.lang.String packagePath, java.io.File sourceFile, org.apache.distributedlog.api.namespace.Namespace dlogNamespace)  
      static void uploadToBookKeeper​(org.apache.distributedlog.api.namespace.Namespace dlogNamespace, java.io.InputStream uploadedInputStream, java.lang.String destPkgPath)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • uploadFileToBookkeeper

        public static void uploadFileToBookkeeper​(java.lang.String packagePath,
                                                  java.io.File sourceFile,
                                                  org.apache.distributedlog.api.namespace.Namespace dlogNamespace)
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • uploadToBookKeeper

        public static void uploadToBookKeeper​(org.apache.distributedlog.api.namespace.Namespace dlogNamespace,
                                              java.io.InputStream uploadedInputStream,
                                              java.lang.String destPkgPath)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • downloadFromBookkeeper

        public static void downloadFromBookkeeper​(org.apache.distributedlog.api.namespace.Namespace namespace,
                                                  java.io.File outputFile,
                                                  java.lang.String packagePath)
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • downloadFromBookkeeper

        public static void downloadFromBookkeeper​(org.apache.distributedlog.api.namespace.Namespace namespace,
                                                  java.io.OutputStream outputStream,
                                                  java.lang.String packagePath)
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • deleteFromBookkeeper

        public static void deleteFromBookkeeper​(org.apache.distributedlog.api.namespace.Namespace namespace,
                                                java.lang.String packagePath)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • getDlogConf

        public static org.apache.distributedlog.DistributedLogConfiguration getDlogConf​(org.apache.pulsar.functions.worker.WorkerConfig workerConfig)
      • newDlogNamespaceURI

        public static java.net.URI newDlogNamespaceURI​(java.lang.String zookeeperServers)
      • initializeDlogNamespace

        public static java.net.URI initializeDlogNamespace​(org.apache.pulsar.common.conf.InternalConfigurationData internalConf)
                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • getPulsarAdminClient

        public static org.apache.pulsar.client.admin.PulsarAdmin getPulsarAdminClient​(java.lang.String pulsarWebServiceUrl)
      • getPulsarAdminClient

        public static org.apache.pulsar.client.admin.PulsarAdmin getPulsarAdminClient​(java.lang.String pulsarWebServiceUrl,
                                                                                      java.lang.String authPlugin,
                                                                                      java.lang.String authParams,
                                                                                      java.lang.String tlsTrustCertsFilePath,
                                                                                      java.lang.Boolean allowTlsInsecureConnection,
                                                                                      java.lang.Boolean enableTlsHostnameVerificationEnable)
      • getPulsarAdminClient

        public static org.apache.pulsar.client.admin.PulsarAdmin getPulsarAdminClient​(java.lang.String pulsarWebServiceUrl,
                                                                                      java.lang.String authPlugin,
                                                                                      java.lang.String authParams,
                                                                                      java.lang.String tlsTrustCertsFilePath,
                                                                                      java.lang.Boolean allowTlsInsecureConnection,
                                                                                      java.lang.Boolean enableTlsHostnameVerificationEnable,
                                                                                      org.apache.pulsar.functions.worker.WorkerConfig workerConfig)
      • getPulsarClient

        public static org.apache.pulsar.client.api.PulsarClient getPulsarClient​(java.lang.String pulsarServiceUrl)
      • getPulsarClient

        public static org.apache.pulsar.client.api.PulsarClient getPulsarClient​(java.lang.String pulsarServiceUrl,
                                                                                java.lang.String authPlugin,
                                                                                java.lang.String authParams,
                                                                                java.lang.Boolean useTls,
                                                                                java.lang.String tlsTrustCertsFilePath,
                                                                                java.lang.Boolean allowTlsInsecureConnection,
                                                                                java.lang.Boolean enableTlsHostnameVerificationEnable)
      • getPulsarClient

        public static org.apache.pulsar.client.api.PulsarClient getPulsarClient​(java.lang.String pulsarServiceUrl,
                                                                                java.lang.String authPlugin,
                                                                                java.lang.String authParams,
                                                                                java.lang.Boolean useTls,
                                                                                java.lang.String tlsTrustCertsFilePath,
                                                                                java.lang.Boolean allowTlsInsecureConnection,
                                                                                java.lang.Boolean enableTlsHostnameVerificationEnable,
                                                                                org.apache.pulsar.functions.worker.WorkerConfig workerConfig)
      • getFunctionInstanceStats

        public static org.apache.pulsar.common.policies.data.FunctionInstanceStatsImpl getFunctionInstanceStats​(java.lang.String fullyQualifiedInstanceName,
                                                                                                                FunctionRuntimeInfo functionRuntimeInfo,
                                                                                                                int instanceId)
      • dumpToTmpFile

        public static java.io.File dumpToTmpFile​(java.io.InputStream uploadedInputStream)
      • createReader

        public static org.apache.pulsar.client.api.Reader<byte[]> createReader​(org.apache.pulsar.client.api.ReaderBuilder readerBuilder,
                                                                               java.lang.String readerName,
                                                                               java.lang.String topic,
                                                                               org.apache.pulsar.client.api.MessageId startMessageId)
                                                                        throws org.apache.pulsar.client.api.PulsarClientException
        Throws:
        org.apache.pulsar.client.api.PulsarClientException
      • createExclusiveProducerWithRetry

        public static org.apache.pulsar.client.api.Producer<byte[]> createExclusiveProducerWithRetry​(org.apache.pulsar.client.api.PulsarClient client,
                                                                                                     java.lang.String topic,
                                                                                                     java.lang.String producerName,
                                                                                                     java.util.function.Supplier<java.lang.Boolean> isLeader,
                                                                                                     int sleepInBetweenMs)
                                                                                              throws WorkerUtils.NotLeaderAnymore
        Throws:
        WorkerUtils.NotLeaderAnymore
      • getIsStillLeaderSupplier

        public static java.util.function.Supplier<java.lang.Boolean> getIsStillLeaderSupplier​(MembershipManager membershipManager,
                                                                                              java.lang.String workerId)