Sends the HUB url a notification of a change in topic

@param hub URL of the hub to notify.
@param topic The Topic that has changed
@throws NotificationException Any failure
776729
public void sendUpdateNotification(final String hub, final String topic) throws NotificationException {
        try {
            final StringBuilder sb = new StringBuilder("hub.mode=publish&hub.url=").append(URLEncoder.encode(topic, "UTF-8"));
            final URL hubUrl = new URL(hub);
            final HttpURLConnection connection = (HttpURLConnection) hubUrl.openConnection();
            // connection.setRequestProperty("Host", hubUrl.getHost());
            connection.setRequestProperty("User-Agent", "ROME-Certiorem");
            connection.setRequestProperty("ContentType", "application/x-www-form-urlencoded");
            connection.setDoOutput(true);
            connection.connect();

            final OutputStream os = connection.getOutputStream();
            os.write(sb.toString().getBytes("UTF-8"));
            os.close();

            final int rc = connection.getResponseCode();
            connection.disconnect();

            if (rc != 204) {
                throw new NotificationException("Server returned an unexcepted response code: " + rc + " " + connection.getResponseMessage());
            }

        } catch (final UnsupportedEncodingException ex) {
            LOG.error("Could not encode URL", ex);
            throw new NotificationException("Could not encode URL", ex);
        } catch (final IOException ex) {
            LOG.error("Communication error", ex);
            throw new NotificationException("Unable to communicate with " + hub, ex);
        }
    }
1341900
public void addTopic(String topic)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "addTopic", topic);

    SelectionCriteria criteria = _messageProcessor.
                                   getSelectionCriteriaFactory().
                                   createSelectionCriteria(topic,
                                                           null,
                                                           SelectorDomain.SIMESSAGE);

    if (_subscriptionState == null)
    {
       _subscriptionState =
        new ConsumerDispatcherState(_destinationHandler.getUuid(), criteria, _destName, _busName);
    }
    else
      _subscriptionState.addSelectionCriteria(criteria);

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "addTopic");
  }
1276678
private void deletePubsubTopic(String topic) throws IOException {
    if (pubsubClient == null) {
      pubsubClient = newPubsubClient(options.as(PubsubOptions.class)).build();
    }
    if (executeNullIfNotFound(pubsubClient.projects().topics().get(topic)) != null) {
      pubsubClient.projects().topics().delete(topic).execute();
    }
  }
137005
public synchronized void addHttpContent(HttpContent httpContent) {
        contentObservable.notifyAddListener(httpContent);
        if (messageFuture != null) {
            if (ioException != null) {
                blockingEntityCollector.addHttpContent(new DefaultLastHttpContent());
                messageFuture.notifyMessageListener(blockingEntityCollector.getHttpContent());
                removeMessageFuture();
                throw new RuntimeException(this.getIoException());
            }
            contentObservable.notifyGetListener(httpContent);
            blockingEntityCollector.addHttpContent(httpContent);
            if (messageFuture.isMessageListenerSet()) {
                messageFuture.notifyMessageListener(blockingEntityCollector.getHttpContent());
            }
            // We remove the feature as the message has reached it life time. If there is a need
            // for using the same message again, we need to set the future again and restart
            // the life-cycle.
            if (httpContent instanceof LastHttpContent) {
                removeMessageFuture();
            }
        } else {
            if (ioException != null) {
                blockingEntityCollector.addHttpContent(new DefaultLastHttpContent());
                throw new RuntimeException(this.getIoException());
            } else {
                blockingEntityCollector.addHttpContent(httpContent);
            }
        }
    }
1126634
private function change_subscription($mode, $topic_url, $http_function = false)
    {
        if (! isset($topic_url)) {
            throw new InvalidArgumentException('Please specify a topic url');
        }

        // lightweight check that we're actually working w/ a valid url
        if (! preg_match('|^https?://|i', $topic_url)) {
            throw new InvalidArgumentException('The specified topic url does not appear to be valid: ' . $topic_url);
        }

        // set the required parameters
        $post_string = 'hub.mode=' . $mode;
        $post_string .= '&hub.callback=' . urlencode($this->callback_url);
        $post_string .= '&hub.topic=' . urlencode($topic_url);

        // add any optional parameter
        if (!is_null($this->verify)) {
            $post_string .= '&hub.verify=' . $this->verify;
        }
        if (!is_null($this->verify_token)) {
            $post_string .= '&hub.verify_token=' . $this->verify_token;
        }
        if (!is_null($this->lease_seconds)) {
            $post_string .= '&hub.lease_seconds=' . $this->lease_seconds;
        }

        // make the http post request and return true/false
        // easy to over-write to use your own http function
        if ($http_function) {
            return call_user_func_array($http_function, [$this->hub_url, $post_string]);
        }

        return $this->http($this->hub_url, $post_string);
    }
1210958
private void  handleLeadershipChange(NotificationContext changeContext) {
    if (this.helixManager.isPresent() && this.helixManager.get().isLeader()) {
      LOGGER.info("Leader notification for {} HM.isLeader {}", this.helixManager.get().getInstanceName(),
          this.helixManager.get().isLeader());

      if (this.isSchedulerEnabled) {
        LOGGER.info("Gobblin Service is now running in master instance mode, enabling Scheduler.");
        this.scheduler.setActive(true);
      }

      if (this.isGitConfigMonitorEnabled) {
        this.gitConfigMonitor.setActive(true);
      }

      if (this.isDagManagerEnabled) {
        //Activate DagManager only if TopologyCatalog is initialized. If not; skip activation.
        if (this.topologyCatalog.getInitComplete().getCount() == 0) {
          this.dagManager.setActive(true);
        }
      }
    } else if (this.helixManager.isPresent()) {
      LOGGER.info("Leader lost notification for {} HM.isLeader {}", this.helixManager.get().getInstanceName(),
          this.helixManager.get().isLeader());
      if (this.isSchedulerEnabled) {
        LOGGER.info("Gobblin Service is now running in slave instance mode, disabling Scheduler.");
        this.scheduler.setActive(false);
      }

      if (this.isGitConfigMonitorEnabled) {
        this.gitConfigMonitor.setActive(false);
      }

      if (this.isDagManagerEnabled) {
        this.dagManager.setActive(false);
      }
    }
  }
666125
private void sendNotification(WingsEndpoint.ShareNotification wingsNotification) {
        // Construct pending intent. The wrapped Intent must not be null as some versions of Android require it.
        Intent intent = wingsNotification.getIntent();
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_ONE_SHOT);

        // Construct notification.
        NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext);
        Notification notification = builder.setSmallIcon(R.drawable.wings__notification)
                .setContentTitle(wingsNotification.getTitle()).setContentText(wingsNotification.getMessage())
                .setTicker(wingsNotification.getTicker()).setAutoCancel(true).setWhen(System.currentTimeMillis())
                .setContentIntent(pendingIntent).build();

        // Send notification.
        NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        if (notificationManager != null) {
            notificationManager.notify(wingsNotification.getId(), notification);
        }
    }
1341194
public void publishInternal(Object message) {
        topicStats.incrementPublishes();
        topicService.publishMessage(name, message, multithreaded);
    }
833929
public void pushMessages(List<Pair<K, V>> messages) {
    for (Pair<K, V> message: messages) {
      this.producer.send(new ProducerRecord<>(topic, message.getKey(), message.getValue()), (recordMetadata, e) -> {
        if (e != null) {
          log.error("Failed to send message to topic {} due to exception: ", topic, e);
        }
      });
    }
  }
1348012
private void sendAnnouncement(InetAddress broadcastAddress) {
        try {
            DatagramPacket announcement = new DatagramPacket(announcementBytes, announcementBytes.length,
                    broadcastAddress, DeviceFinder.ANNOUNCEMENT_PORT);
            socket.get().send(announcement);
            Thread.sleep(getAnnounceInterval());
        } catch (Throwable t) {
            logger.warn("Unable to send announcement packet, shutting down", t);
            stop();
        }
    }
968135
public function publish_update($topic_urls, $http_function = false)
    {
        if (! isset($topic_urls)) {
            throw new InvalidArgumentException('Please specify a topic url');
        }

        // check that we're working with an array
        if (! is_array($topic_urls)) {
            $topic_urls = [$topic_urls];
        }

        // set the mode to publish
        $post_string = 'hub.mode=publish';
        // loop through each topic url
        foreach ($topic_urls as $topic_url) {

            // lightweight check that we're actually working w/ a valid url
            if (! preg_match('|^https?://|i', $topic_url)) {
                throw new InvalidArgumentException('The specified topic url does not appear to be valid: ' . $topic_url);
            }

            // append the topic url parameters
            $post_string .= '&hub.url=' . urlencode($topic_url);
        }

        // make the http post request and return true/false
        // easy to over-write to use your own http function
        if ($http_function) {
            return $http_function($this->hub_url, $post_string);
        }

        return $this->http_post($this->hub_url, $post_string);
    }
77427
@Override
  public void doPushNotificationAnswerEvent(ServerShSession session, PushNotificationRequest request, PushNotificationAnswer answer)
      throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
    // TODO Auto-generated method stub
  }
649317
@Override
	public TopicPublisher createPublisher(Topic topic) throws JMSException
    {
    	externalAccessLock.readLock().lock();
    	try
		{
	        checkNotClosed();
	        LocalTopicPublisher publisher = new LocalTopicPublisher(this,topic,idProvider.createID());
	        registerProducer(publisher);
	        return publisher;
		}
    	finally
    	{
    		externalAccessLock.readLock().unlock();
    	}
    }
1265955
public boolean publish(String topicName, DefaultMessage message,boolean asynSend){
		if(routeEnv != null)topicName = routeEnv + "." + topicName;
		return producer.publish(topicName, message,asynSend);
	}
776525
protected void setupNotificationArea() throws Throwable {
        final String sourceMethod = "setupNotificationArea";

        URL notificationsURL = null;
        HttpsURLConnection connection = null;
        try {
            // Get URL for creating a notification area
            notificationsURL = serverConnection.getNotificationsURL();

            if (logger.isLoggable(Level.FINEST)) {
                logger.logp(Level.FINEST, logger.getName(), sourceMethod, "[" + RESTClientMessagesUtil.getObjID(this) + "] About to call notificationURL: " + notificationsURL);
            }

            // Get connection to server
            connection = serverConnection.getConnection(notificationsURL, HttpMethod.POST, true);

            // Create NotificationSettings object
            NotificationSettings ns = new NotificationSettings();
            ns.deliveryInterval = serverConnection.getConnector().getNotificationDeliveryInterval();
            ns.inboxExpiry = serverConnection.getConnector().getNotificationInboxExpiry();

            // Write CreateMBean JSON to connection output stream
            OutputStream output = connection.getOutputStream();
            converter.writeNotificationSettings(output, ns);
            output.flush();
        } catch (ConnectException ce) {
            // Server is down; not a client bug
            throw ce;
        } catch (IOException io) {
            throw serverConnection.getRequestErrorException(sourceMethod, io, notificationsURL);
        }

        // Check response code from server
        final int responseCode = connection.getResponseCode();

        if (logger.isLoggable(Level.FINEST)) {
            logger.logp(Level.FINEST, logger.getName(), sourceMethod, "Received responseCode: " + responseCode);
        }

        switch (responseCode) {
            case HttpURLConnection.HTTP_OK:
                JSONConverter converter = JSONConverter.getConverter();
                try {
                    // Process and return server response, which should be a NotificationArea
                    NotificationArea area = converter.readNotificationArea(connection.getInputStream());

                    inboxURL = new DynamicURL(serverConnection.connector, area.inboxURL);
                    registrationsURL = new DynamicURL(serverConnection.connector, area.registrationsURL);
                    serverRegistrationsURL = new DynamicURL(serverConnection.connector, area.serverRegistrationsURL);
                    notificationClientURL = new DynamicURL(serverConnection.connector, area.clientURL);

                    if (logger.isLoggable(Level.FINER)) {
                        logger.logp(Level.FINER, logger.getName(), "setupNotificationArea", "Successfully setup inboxURL: " + inboxURL.getURL());
                    }
                    break;
                } catch (Exception e) {
                    throw serverConnection.getResponseErrorException(sourceMethod, e, notificationsURL);
                } finally {
                    JSONConverter.returnConverter(converter);
                }
            case HttpURLConnection.HTTP_NOT_FOUND:
                throw new IOException(RESTClientMessagesUtil.getMessage(RESTClientMessagesUtil.URL_NOT_FOUND));
            case HttpURLConnection.HTTP_UNAVAILABLE:
            case HttpURLConnection.HTTP_BAD_REQUEST:
            case HttpURLConnection.HTTP_INTERNAL_ERROR:
                // Server response should be a serialized Throwable
                throw serverConnection.getServerThrowable(sourceMethod, connection);
            case HttpURLConnection.HTTP_UNAUTHORIZED:
            case HttpURLConnection.HTTP_FORBIDDEN:
                throw serverConnection.getBadCredentialsException(responseCode, connection);
            default:
                throw serverConnection.getResponseCodeErrorException(sourceMethod, responseCode, connection);
        }
    }
1294783
def topic(self, channel, new_topic=None, tags=None):
        """"""
        params = [channel]
        if new_topic:
            params += new_topic
        self.send('TOPIC', params=params, source=self.nick, tags=tags)
934296
protected void sendSubscribe(String topic) {
    assert topic != null : "topic shouldn't be null";
    JsonObject msg = Json.createObject().set(TYPE, "register").set(TOPIC, topic);
    send(msg);
  }