Examples of ConnectionBean


Examples of net.tomp2p.connection.ConnectionBean

    final Peer peer = new Peer(p2pID, peerId, peerCreator);

    PeerBean peerBean = peerCreator.peerBean();
    peerBean.addPeerStatusListener(peerMap);
   
    ConnectionBean connectionBean = peerCreator.connectionBean();

    peerBean.peerMap(peerMap);
    peerBean.keyPair(keyPair);

    if (bloomfilterFactory == null) {
      peerBean.bloomfilterFactory(new DefaultBloomfilterFactory());
    }

    if (broadcastHandler == null) {
      broadcastHandler = new DefaultBroadcastHandler(peer, new Random());
    }
   
    //Set/enable RPC

    if (isEnableHandShakeRPC()) {
      PingRPC pingRPC = new PingRPC(peerBean, connectionBean);
      peer.pingRPC(pingRPC);
    }
   
    if (isEnableQuitRPC()) {
      QuitRPC quitRPC = new QuitRPC(peerBean, connectionBean);
      quitRPC.addPeerStatusListener(peerMap);
      peer.quitRPC(quitRPC);
    }

    if (isEnableNeighborRPC()) {
      NeighborRPC neighborRPC = new NeighborRPC(peerBean, connectionBean);
      peer.neighborRPC(neighborRPC);
    }

    if (isEnableDirectDataRPC()) {
      DirectDataRPC directDataRPC = new DirectDataRPC(peerBean, connectionBean);
      peer.directDataRPC(directDataRPC);
    }

    if (isEnableBroadcast()) {
      BroadcastRPC broadcastRPC = new BroadcastRPC(peerBean, connectionBean, broadcastHandler);
      peer.broadcastRPC(broadcastRPC);
    }
   
    if (isEnableRouting() && isEnableNeighborRPC()) {
      DistributedRouting routing = new DistributedRouting(peerBean, peer.neighborRPC());
      peer.distributedRouting(routing);
    }

    if (maintenanceTask == null && isEnableMaintenance()) {
      maintenanceTask = new MaintenanceTask();
    }

    if (maintenanceTask != null) {
      maintenanceTask.init(peer, connectionBean.timer());
      maintenanceTask.addMaintainable(peerMap);
    }
    peerBean.maintenanceTask(maintenanceTask);


    // set the ping builder for the heart beat
    connectionBean.sender().pingBuilderFactory(new PingBuilderFactory() {     
      @Override
      public PingBuilder create() {
        return peer.ping();
      }
    });
View Full Code Here

Examples of org.apache.sqoop.json.ConnectionBean

    } else {
      response = super.get(serverUrl + RESOURCE + xid);
    }
    JSONObject jsonObject = (JSONObject)JSONValue.parse(response);

    ConnectionBean connectionBean = new ConnectionBean();
    connectionBean.restore(jsonObject);

    return connectionBean;
  }
View Full Code Here

Examples of org.apache.sqoop.json.ConnectionBean

    return connectionBean;
  }

  public ValidationBean create(String serverUrl, MConnection connection) {

    ConnectionBean connectionBean = new ConnectionBean(connection);

    // Extract all form inputs including sensitive inputs
    JSONObject connectionJson = connectionBean.extract(false);

    String response = super.post(serverUrl + RESOURCE,
                                 connectionJson.toJSONString());

    ValidationBean validationBean = new ValidationBean();
View Full Code Here

Examples of org.apache.sqoop.json.ConnectionBean

    return validationBean;
  }

  public ValidationBean update(String serverUrl, MConnection connection) {

    ConnectionBean connectionBean = new ConnectionBean(connection);

    // Extract all form inputs including sensitive inputs
    JSONObject connectionJson = connectionBean.extract(false);

    String response = super.put(serverUrl + RESOURCE
                                  + connection.getPersistenceId(),
                                connectionJson.toJSONString());
View Full Code Here

Examples of org.apache.sqoop.json.ConnectionBean

//    String sxid = ctx.getLastURLElement();
//    long xid = Long.valueOf(sxid);

    String username = ctx.getUserName();

    ConnectionBean bean = new ConnectionBean();

    try {
      JSONObject json =
        (JSONObject) JSONValue.parse(ctx.getRequest().getReader());

      bean.restore(json);
    } catch (IOException e) {
      throw new SqoopException(ServerError.SERVER_0003,
        "Can't read request content", e);
    }

    // Get connection object
    List<MConnection> connections = bean.getConnections();

    if(connections.size() != 1) {
      throw new SqoopException(ServerError.SERVER_0003,
        "Expected one connection metadata but got " + connections.size());
    }
View Full Code Here

Examples of org.apache.sqoop.json.ConnectionBean

    return outputBean;
  }

  private JsonBean getConnections(RequestContext ctx) {
    String sxid = ctx.getLastURLElement();
    ConnectionBean bean;

    AuditLoggerManager.getInstance()
        .logAuditEvent(ctx.getUserName(), ctx.getRequest().getRemoteAddr(),
        "get", "connection", sxid);

    Locale locale = ctx.getAcceptLanguageHeader();
    Repository repository = RepositoryManager.getInstance().getRepository();

    if (sxid.equals("all")) {

      List<MConnection> connections = repository.findConnections();
      bean = new ConnectionBean(connections);

      // Add associated resources into the bean
      for( MConnection connection : connections) {
        long connectorId = connection.getConnectorId();
        if(!bean.hasConnectorBundle(connectorId)) {
          bean.addConnectorBundle(connectorId,
            ConnectorManager.getInstance().getResourceBundle(connectorId, locale));
        }
      }
    } else {
      long xid = Long.valueOf(sxid);

      MConnection connection = repository.findConnection(xid);
      long connectorId = connection.getConnectorId();

      bean = new ConnectionBean(connection);

      bean.addConnectorBundle(connectorId,
        ConnectorManager.getInstance().getResourceBundle(connectorId, locale));
    }

    // Sent framework resource bundle in all cases
    bean.setFrameworkBundle(FrameworkManager.getInstance().getBundle(locale));

    return bean;
  }
View Full Code Here

Examples of org.apache.sqoop.json.ConnectionBean

  private JsonBean createUpdateConnection(RequestContext ctx, boolean update) {
//    Check that given ID equals with sent ID, otherwise report an error UPDATE
//    String sxid = ctx.getLastURLElement();
//    long xid = Long.valueOf(sxid);

    ConnectionBean bean = new ConnectionBean();

    try {
      JSONObject json =
        (JSONObject) JSONValue.parse(ctx.getRequest().getReader());
      bean.restore(json);
    } catch (IOException e) {
      throw new SqoopException(ServerError.SERVER_0003,
        "Can't read request content", e);
    }

    // Get connection object
    List<MConnection> connections = bean.getConnections();

    if(connections.size() != 1) {
      throw new SqoopException(ServerError.SERVER_0003,
        "Expected one connection metadata but got " + connections.size());
    }
View Full Code Here

Examples of org.apache.sqoop.json.ConnectionBean

    return outputBean;
  }

  private JsonBean getConnections(RequestContext ctx) {
    String sxid = ctx.getLastURLElement();
    ConnectionBean bean;

    Locale locale = ctx.getAcceptLanguageHeader();
    Repository repository = RepositoryManager.getRepository();

    if (sxid.equals("all")) {

      List<MConnection> connections = repository.findConnections();
      bean = new ConnectionBean(connections);

      // Add associated resources into the bean
      for( MConnection connection : connections) {
        long connectorId = connection.getConnectorId();
        if(!bean.hasConnectorBundle(connectorId)) {
          bean.addConnectorBundle(connectorId,
            ConnectorManager.getResourceBundle(connectorId, locale));
        }
      }
    } else {
      long xid = Long.valueOf(sxid);

      MConnection connection = repository.findConnection(xid);
      long connectorId = connection.getConnectorId();

      bean = new ConnectionBean(connection);

      bean.addConnectorBundle(connectorId,
        ConnectorManager.getResourceBundle(connectorId, locale));
    }

    // Sent framework resource bundle in all cases
    bean.setFrameworkBundle(FrameworkManager.getBundle(locale));

    return bean;
  }
View Full Code Here

Examples of org.apache.sqoop.json.ConnectionBean

    io.out.println(MessageFormat.format(getResource().getString(Constants
        .RES_CLONE_CLONING_CONN), connectionId ));

    ConsoleReader reader = new ConsoleReader();

    ConnectionBean connectionBean = readConnection(connectionId);

    // TODO(jarcec): Check that we have expected data
    MConnection connection = connectionBean.getConnections().get(0);
    ResourceBundle frameworkBundle
      = connectionBean.getFrameworkBundle();
    ResourceBundle connectorBundle
      = connectionBean.getConnectorBundle(connection.getConnectorId());

    // Remove persistent id as we're making a clone
    connection.setPersistenceId(MPersistableEntity.PERSISTANCE_ID_DEFAULT);

    Status status = Status.FINE;
View Full Code Here

Examples of org.apache.sqoop.json.ConnectionBean

    } else {
      response = super.get(serverUrl + RESOURCE + xid);
    }
    JSONObject jsonObject = (JSONObject)JSONValue.parse(response);

    ConnectionBean connectionBean = new ConnectionBean();
    connectionBean.restore(jsonObject);

    return connectionBean;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.