Creates an availability group listener
489765
def sqlvm_aglistener_create(client, cmd, availability_group_listener_name, sql_virtual_machine_group_name,
                            resource_group_name, availability_group_name, ip_address, subnet_resource_id,
                            load_balancer_resource_id, probe_port, sql_virtual_machine_instances, port=1433,
                            public_ip_address_resource_id=None):
    '''
    
    '''

    if not is_valid_resource_id(subnet_resource_id):
        raise CLIError("Invalid subnet resource id.")
    if not is_valid_resource_id(load_balancer_resource_id):
        raise CLIError("Invalid load balancer resource id.")
    if public_ip_address_resource_id and not is_valid_resource_id(public_ip_address_resource_id):
        raise CLIError("Invalid public IP address resource id.")
    for sqlvm in sql_virtual_machine_instances:
        if not is_valid_resource_id(sqlvm):
            raise CLIError("Invalid SQL virtual machine resource id.")

    # Create the private ip address
    private_ip_object = PrivateIPAddress(ip_address=ip_address,
                                         subnet_resource_id=subnet_resource_id
                                         if is_valid_resource_id(subnet_resource_id) else None)

    # Create the load balancer configurations
    load_balancer_object = LoadBalancerConfiguration(private_ip_address=private_ip_object,
                                                     public_ip_address_resource_id=public_ip_address_resource_id,
                                                     load_balancer_resource_id=load_balancer_resource_id,
                                                     probe_port=probe_port,
                                                     sql_virtual_machine_instances=sql_virtual_machine_instances)

    # Create the availability group listener object
    ag_listener_object = AvailabilityGroupListener(availability_group_name=availability_group_name,
                                                   load_balancer_configurations=load_balancer_object,
                                                   port=port)

    LongRunningOperation(cmd.cli_ctx)(sdk_no_wait(False, client.create_or_update, resource_group_name,
                                                  sql_virtual_machine_group_name, availability_group_listener_name,
                                                  ag_listener_object))

    return client.get(resource_group_name, sql_virtual_machine_group_name, availability_group_listener_name)
1169019
def add_listener(self, name, listener, priority=0):
        
        if name not in self.listeners:
            self.listeners[name] = []

        self.listeners[name].append((listener, priority))

        # reorder event
        self.listeners[name].sort(key=lambda listener: listener[1], reverse=True)
1295235
private void createListener(final JsMessagingEngine messagingEngine)
            throws ResourceException {

        final String methodName = "createListener";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName, messagingEngine);
        }

        final SibRaMessagingEngineConnection connection = getConnection(messagingEngine);
        createListener(connection);

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }

    }
945823
function addListeners() {
	if (listenersAdded) return;
	listenersAdded = true;

	if (cluster.isMaster) {
		// Listen for worker responses to requests for local metrics
		cluster.on('message', (worker, message) => {
			if (message.type === GET_METRICS_RES) {
				const request = requests.get(message.requestId);
				message.metrics.forEach(registry => request.responses.push(registry));
				request.pending--;

				if (request.pending === 0) {
					// finalize
					requests.delete(message.requestId);
					clearTimeout(request.errorTimeout);

					if (request.failed) return; // Callback already run with Error.

					const registry = AggregatorRegistry.aggregate(request.responses);
					const promString = registry.metrics();
					request.done(null, promString);
				}
			}
		});
	}
}
1153085
private CmsUploadListener createListener() {

        CmsUploadListener listener = new CmsUploadListener(getRequest().getContentLength());
        listener.setDelay(m_uploadDelay);
        m_listeners.put(listener.getId(), listener);
        getRequest().getSession().setAttribute(SESSION_ATTRIBUTE_LISTENER_ID, listener.getId());
        return listener;
    }
172954
@Override
    public void doSessionClosedListeners() {
        runManagementTask(new Runnable() {
            @Override
            public void run() {
                try {
                    // The particular management listeners change on strategy, so get them here.
                    for (final SessionManagementListener listener : getManagementListeners()) {
                        listener.doSessionClosed(SessionManagementBeanImpl.this);
                    }

                    // XXX should there be a markChanged() here because the session status is now closed?
                    // Or is that covered by the fact we generate a session-closed message?
                } catch (Exception ex) {
                    logger.warn("Error during doSessionClosed session listener notifications:", ex);
                }
            }
        });
    }
851548
def _create_event_listeners(self):
        """"""
        LOG.debug("Create the event listeners.")
        for event_type, callback in self._event_callback_pairs:
            LOG.debug("Create listener for %r event", event_type)
            listener = self._utils.get_vnic_event_listener(event_type)
            eventlet.spawn_n(listener, callback)
207062
public  void addEventSourceListener(EventSourceListener listener) {
        LOG.entering(CLASS_NAME, "addEventSourceListener", listener);
        _getDelegate().addEventSourceListener(listener);
    }
1069578
private void createListener(final SibRaMessagingEngineConnection connection)
            throws ResourceException {

        final String methodName = "createListener";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName, connection);
        }

        final SIDestinationAddress destination = _endpointConfiguration
                .getDestination();

        try {

            connection.createListener(destination, _messageEndpointFactory);

        } catch (final IllegalStateException exception) {

            // No FFDC code needed
            throw exception;

        } catch (final ResourceException exception) {

            // No FFDC code needed

            if (_remoteDestination) {

                SibTr.warning(TRACE, SibTr.Suppressor.ALL_FOR_A_WHILE_SIMILAR_INSERTS, "ATTACH_FAILED_CWSIV0769", new Object[] {
                        destination.getDestinationName(),
                        _endpointConfiguration.getBusName(), this, exception });

                /*
                 * Try again 30 seconds later
                 */

                _timer.schedule(new TimerTask() {

                    public void run() {

                        try {

                            createListener(connection);

                        } catch (final ResourceException retryException) {
                            // No FFDC code needed
                        }

                    }
                }, RETRY_INTERVAL);

            } else {

                throw exception;

            }

        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }

    }
312968
def add_listener(self, listener):
        
        self.logger.debug('installing listener %r', listener)
        if not isinstance(listener, SessionListener):
            raise SessionError("Listener must be a SessionListener type")
        with self._lock:
            self._listeners.add(listener)
662859
def new_cast_status(self, cast_status):
        """"""
        casts = self._casts
        group_members = self._mz.members
        for member_uuid in group_members:
            if member_uuid not in casts:
                continue
            for listener in list(casts[member_uuid]['listeners']):
                listener.multizone_new_cast_status(
                    self._group_uuid, cast_status)
310820
@Override
    public void doSessionCreatedListeners() {
        runManagementTask(new Runnable() {
            @Override
            public void run() {
                try {
                    // The particular management listeners change on strategy, so get them here.
                    for (final SessionManagementListener listener : getManagementListeners()) {
                        listener.doSessionCreated(SessionManagementBeanImpl.this);
                    }

                    // XXX Should we include a 'markChanged()' here?
                } catch (Exception ex) {
                    logger.warn("Error during doSessionCreated session listener notifications:", ex);
                }
            }
        });
    }
143770
@Override
	public void broadcast(String name, Tree payload, Groups groups, boolean local) {
		String key = getCacheKey(name, groups);
		ListenerEndpoint[] endpoints;
		if (local) {
			endpoints = localBroadcasterCache.get(key);
		} else {
			endpoints = broadcasterCache.get(key);
		}
		if (endpoints == null) {
			HashSet<ListenerEndpoint> list = new HashSet<>();
			readLock.lock();
			try {
				for (Map.Entry<String, HashMap<String, Strategy<ListenerEndpoint>>> entry : listeners.entrySet()) {
					if (Matcher.matches(name, entry.getKey())) {
						for (Map.Entry<String, Strategy<ListenerEndpoint>> test : entry.getValue().entrySet()) {
							if (groups != null) {
								final String testGroup = test.getKey();
								for (String group : groups.groups()) {
									if (group.equals(testGroup)) {
										for (ListenerEndpoint endpoint : test.getValue().getAllEndpoints()) {
											if (local) {
												if (endpoint.isLocal()) {
													list.add(endpoint);
												}
											} else {
												list.add(endpoint);
											}
										}
									}
								}
							} else {
								if (local) {
									for (ListenerEndpoint endpoint : test.getValue().getAllEndpoints()) {
										if (local) {
											list.add(endpoint);
										}
									}
								} else {
									list.addAll(test.getValue().getAllEndpoints());
								}
							}
						}
					}
				}
			} finally {
				readLock.unlock();
			}
			endpoints = new ListenerEndpoint[list.size()];
			list.toArray(endpoints);
			if (local) {
				localBroadcasterCache.put(key, endpoints);
			} else {
				broadcasterCache.put(key, endpoints);
			}
		}
		if (endpoints.length == 0) {
			return;
		}
		if (endpoints.length == 1) {
			try {
				endpoints[0].on(name, payload, groups, true);
			} catch (Exception cause) {
				logger.error("Unable to invoke event listener!", cause);
			}
			return;
		}
		HashSet<String> nodeSet = new HashSet<>(endpoints.length * 2);
		for (ListenerEndpoint endpoint : endpoints) {
			if (endpoint.isLocal() || nodeSet.add(endpoint.getNodeID())) {
				try {
					endpoint.on(name, payload, groups, true);
				} catch (Exception cause) {
					logger.error("Unable to invoke event listener!", cause);
				}
			}
		}
	}
529372
private void scheduleCreateRemoteListener() {

        final String methodName = "scheduleCreateRemoteListener";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName);
        }

        _timer.schedule(new TimerTask() {

            public void run() {

                createRemoteListenerDeactivateOnException(false);

                synchronized(SibRaStaticDestinationEndpointActivation.this) {

                    if (_remoteConnection != null) {

                        /*
                         * Successfully created a connection
                         */

                        SibTr.info(TRACE, "CONNECTED_CWSIV0777", new Object[] {
                                _remoteConnection.getConnection().getMeName(),
                                _endpointConfiguration.getDestination()
                                        .getDestinationName(),
                                _endpointConfiguration.getBusName(),
                                SibRaStaticDestinationEndpointActivation.this });

                    }

                }

            }
        }, RETRY_INTERVAL);

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }

    }
1238839
private void createListener(final SibRaMessagingEngineConnection connection)
                    throws ResourceException
    {

        final String methodName = "createListener";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled())
        {
            SibTr.entry(this, TRACE, methodName, connection);
        }

        if (_endpointConfiguration.getUseDestinationWildcard())
        {
            createMultipleListeners(connection);
        }
        else
        {
            createSingleListener(connection);
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }

    }
1331844
def construct_listener(outfile=None):
    """"""
    if outfile is not None:
        if os.path.exists(outfile):
            raise IOError("File %s already exists" % outfile)
        
        outfile = open(outfile, 'wb')

    return PrintingListener(out=outfile)
109914
private void notifyListener(RequestResponseClass clazz, 
	        ISFSObject params, User user, Object userAgent) throws Exception {
	    Object listener = clazz.newInstance();
	    setDataToListener(clazz, listener, params);
	    invokeExecuteMethod(clazz.getExecuteMethod(), listener, userAgent);
	    responseClient(clazz, listener, user);
	}