Refine search
public void bind() throws IOException { URI bind = getBindLocation(); String host = bind.getHost(); host = (host == null || host.length() == 0) ? "localhost" : host; InetAddress addr = InetAddress.getByName(host); try { serverSocket = serverSocketFactory.createServerSocket(bind.getPort(), backlog, addr); configureServerSocket(serverSocket); } catch (IOException e) { throw IOExceptionSupport.create("Failed to bind to server socket: " + bind + " due to: " + e, e); } try { setConnectURI(new URI(bind.getScheme(), bind.getUserInfo(), resolveHostName(serverSocket, addr), serverSocket.getLocalPort(), bind.getPath(), bind.getQuery(), bind.getFragment())); } catch (URISyntaxException e) { // it could be that the host name contains invalid characters such // as _ on unix platforms so lets try use the IP address instead try { setConnectURI(new URI(bind.getScheme(), bind.getUserInfo(), addr.getHostAddress(), serverSocket.getLocalPort(), bind.getPath(), bind.getQuery(), bind.getFragment())); } catch (URISyntaxException e2) { throw IOExceptionSupport.create(e2); } } }
@Override public Object unmarshal(DataInput dis) throws IOException { DataInput dataIn = dis; if (!sizePrefixDisabled) { int size = dis.readInt(); if (size > maxFrameSize) { throw IOExceptionSupport.createFrameSizeException(size, maxFrameSize); } // int size = dis.readInt(); // byte[] data = new byte[size]; // dis.readFully(data); // bytesIn.restart(data); // dataIn = bytesIn; } return doUnmarshal(dataIn); }
public static IOException createFrameSizeException(int size, long maxSize) { return new IOException("Frame size of " + toHumanReadableSizeString(size) + " larger than max allowed " + toHumanReadableSizeString(maxSize)); }
protected DiscoveryAgent doCreateDiscoveryAgent(URI uri) throws IOException { try { if (LOG.isTraceEnabled()) { LOG.trace("doCreateDiscoveryAgent: uri = " + uri.toString()); } MulticastDiscoveryAgent mda = new MulticastDiscoveryAgent(); mda.setDiscoveryURI(uri); // allow MDA's params to be set via query arguments // (e.g., multicast://default?group=foo Map options = URISupport.parseParameters(uri); IntrospectionSupport.setProperties(mda, options); return mda; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create discovery agent: " + uri, e); } } }
String group = location.getHost(); String broker = URISupport.stripPrefix(location.getPath(), "/"); final Map<String, String> brokerOptions = new HashMap<String, String>(URISupport.parseParameters(location)); if (!brokerOptions.containsKey("persistent")) { brokerOptions.put("persistent", "false"); final URI finalLocation = new URI("vm://" + broker); final String finalBroker = broker; final String finalGroup = group; throw IOExceptionSupport.create(e);
location = new URI("vm://" + host); } else { throw IOExceptionSupport.create(e1); broker = BrokerFactory.createBroker(brokerURI); broker.start(); MDC.put("activemq.broker", broker.getBrokerName()); } catch (URISyntaxException e) { throw IOExceptionSupport.create(e); connector.setBrokerService(broker); connector.setUri(location); connector.setTaskRunnerFactory(broker.getTaskRunnerFactory()); connector.start(); CONNECTORS.put(host, connector); IntrospectionSupport.setProperties(vmtransport.peer, new HashMap<String,String>(options)); IntrospectionSupport.setProperties(vmtransport, options); Transport transport = vmtransport; if (vmtransport.isMarshal()) {
protected DiscoveryAgent doCreateDiscoveryAgent(URI uri) throws IOException { try { Map options = URISupport.parseParameters(uri); ZeroconfDiscoveryAgent rc = new ZeroconfDiscoveryAgent(); rc.setGroup(uri.getHost()); IntrospectionSupport.setProperties(rc, options); return rc; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create discovery agent: " + uri, e); } } }
public Transport doConnect(URI location) throws Exception { try { Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location)); if( !options.containsKey("wireFormat.host") ) { options.put("wireFormat.host", location.getHost()); } WireFormat wf = createWireFormat(options); Transport transport = createTransport(location, wf); Transport rc = configure(transport, wf, options); //remove auto IntrospectionSupport.extractProperties(options, "auto."); if (!options.isEmpty()) { throw new IllegalArgumentException("Invalid connect parameters: " + options); } return rc; } catch (URISyntaxException e) { throw IOExceptionSupport.create(e); } }
/** * @param uri * @return * @throws IOException */ private static DiscoveryAgentFactory findDiscoveryAgentFactory(URI uri) throws IOException { String scheme = uri.getScheme(); if (scheme == null) { throw new IOException("DiscoveryAgent scheme not specified: [" + uri + "]"); } DiscoveryAgentFactory daf = DISCOVERY_AGENT_FACTORYS.get(scheme); if (daf == null) { // Try to load if from a META-INF property. try { daf = (DiscoveryAgentFactory)DISCOVERY_AGENT_FINDER.newInstance(scheme); DISCOVERY_AGENT_FACTORYS.put(scheme, daf); } catch (Throwable e) { throw IOExceptionSupport.create("DiscoveryAgent scheme NOT recognized: [" + scheme + "]", e); } } return daf; }
@Override public TransportServer doBind(final URI location) throws IOException { try { Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location)); if (options.containsKey("port")) { throw new IllegalArgumentException("The port property cannot be specified on a UDP server transport - please use the port in the URI syntax"); } WireFormat wf = createWireFormat(options); int port = location.getPort(); OpenWireFormat openWireFormat = asOpenWireFormat(wf); UdpTransport transport = (UdpTransport) createTransport(location.getPort(), wf); Transport configuredTransport = configure(transport, wf, options, true); UdpTransportServer server = new UdpTransportServer(location, transport, configuredTransport, createReplayStrategy()); return server; } catch (URISyntaxException e) { throw IOExceptionSupport.create(e); } catch (Exception e) { throw IOExceptionSupport.create(e); } }
protected DiscoveryAgent doCreateDiscoveryAgent(URI uri) throws IOException { try { OsgiDiscoveryAgent rc = new OsgiDiscoveryAgent(); rc.setPropertyName(uri.getSchemeSpecificPart()); return rc; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create discovery agent: " + uri, e); } } }
@Override public TransportServer doBind(final URI location) throws IOException { try { Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location)); ServerSocketFactory serverSocketFactory = createServerSocketFactory(); TcpTransportServer server = createTcpTransportServer(location, serverSocketFactory); server.setWireFormatFactory(createWireFormatFactory(options)); IntrospectionSupport.setProperties(server, options); Map<String, Object> transportOptions = IntrospectionSupport.extractProperties(options, "transport."); server.setTransportOption(transportOptions); server.bind(); return server; } catch (URISyntaxException e) { throw IOExceptionSupport.create(e); } }
if (isSchedulerSupport()) { SchedulerBroker sb = new SchedulerBroker(this, broker, getJobSchedulerStore()); if (isUseJmx()) { JobSchedulerViewMBean view = new JobSchedulerView(sb.getJobScheduler()); try { this.adminView.setJMSJobScheduler(objectName); } catch (Throwable e) { throw IOExceptionSupport.create("JobScheduler could not be registered in JMX: " + e.getMessage(), e); AnnotatedMBean.registerMBean(getManagementContext(), statusView, objectName); } catch (Throwable e) { throw IOExceptionSupport.create("Status MBean could not be registered in JMX: " + e.getMessage(), e);
protected void registerJmsConnectorMBean(JmsConnector connector) throws IOException { JmsConnectorView view = new JmsConnectorView(connector); try { ObjectName objectName = BrokerMBeanSupport.createNetworkConnectorName(getBrokerObjectName(), "jmsConnectors", connector.getName()); AnnotatedMBean.registerMBean(getManagementContext(), view, objectName); } catch (Throwable e) { throw IOExceptionSupport.create("Broker could not be registered in JMX: " + e.getMessage(), e); } }
protected DiscoveryAgent doCreateDiscoveryAgent(URI uri) throws IOException { try { CompositeData data = URISupport.parseComposite(uri); Map options = data.getParameters(); SimpleDiscoveryAgent rc = new SimpleDiscoveryAgent(); IntrospectionSupport.setProperties(rc, options); rc.setServices(data.getComponents()); return rc; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create discovery agent: " + uri, e); } } }
protected void unregisterConnectorMBean(TransportConnector connector) throws IOException { if (isUseJmx()) { try { ObjectName objectName = createConnectorObjectName(connector); getManagementContext().unregisterMBean(objectName); } catch (Throwable e) { throw IOExceptionSupport.create( "Transport Connector could not be unregistered in JMX: " + e.getMessage(), e); } } }
public void registerNetworkConnectorMBean(NetworkConnector connector) throws IOException { NetworkConnectorViewMBean view = new NetworkConnectorView(connector); try { ObjectName objectName = createNetworkConnectorObjectName(connector); connector.setObjectName(objectName); AnnotatedMBean.registerMBean(getManagementContext(), view, objectName); } catch (Throwable e) { throw IOExceptionSupport.create("Network Connector could not be registered in JMX: " + e.getMessage(), e); } }
protected ObjectName createObjectName(String type, String value) throws IOException { try { return BrokerMBeanSupport.createConnectionViewByType(connectorName, type, value); } catch (Throwable e) { throw IOExceptionSupport.create(e); } }
protected WireFormatFactory createWireFormatFactory(Map<String, String> options) throws IOException { String wireFormat = options.remove("wireFormat"); if (wireFormat == null) { wireFormat = getDefaultWireFormatType(); } try { WireFormatFactory wff = (WireFormatFactory)WIREFORMAT_FACTORY_FINDER.newInstance(wireFormat); IntrospectionSupport.setProperties(wff, options, "wireFormat."); return wff; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create wire format factory for: " + wireFormat + ", reason: " + e, e); } }
private PersistenceAdapter kahaDBFromTemplate(PersistenceAdapter template) throws IOException { try { Map<String, Object> configuration = new HashMap<String, Object>(); IntrospectionSupport.getProperties(template, configuration, null); PersistenceAdapter adapter = template.getClass().newInstance(); IntrospectionSupport.setProperties(adapter, configuration); return adapter; } catch (Exception e) { throw IOExceptionSupport.create(e); } }