Class WorkerUtils

java.lang.Object
org.apache.pulsar.functions.worker.WorkerUtils

public final class WorkerUtils extends Object
  • Method Details

    • uploadFileToBookkeeper

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

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

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

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

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

      public static org.apache.distributedlog.DistributedLogConfiguration getDlogConf(WorkerConfig workerConfig)
    • newDlogNamespaceURI

      public static URI newDlogNamespaceURI(String zookeeperServers)
    • initializeDlogNamespace

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

      public static PulsarAdmin getPulsarAdminClient(String pulsarWebServiceUrl, String authPlugin, String authParams, String tlsTrustCertsFilePath, Boolean allowTlsInsecureConnection, Boolean enableTlsHostnameVerification, WorkerConfig workerConfig)
    • getPulsarClient

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

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

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

      public static File dumpToTmpFile(InputStream uploadedInputStream)
    • createReader

      public static org.apache.pulsar.client.api.Reader<byte[]> createReader(org.apache.pulsar.client.api.ReaderBuilder readerBuilder, String readerName, 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, String topic, String producerName, Supplier<Boolean> isLeader, int sleepInBetweenMs) throws WorkerUtils.NotLeaderAnymore
      Throws:
      WorkerUtils.NotLeaderAnymore
    • getIsStillLeaderSupplier

      public static Supplier<Boolean> getIsStillLeaderSupplier(MembershipManager membershipManager, String workerId)