Connect the device to other device with a link

@param device
@param link
@throws TooManyConnectionException
164748
public void connectToDeviceWithLink(Device device, Link link)
            throws ShanksException {
        this.connectToLink(link);
        try {
            device.connectToLink(link);
        } catch (ShanksException e) {
            this.disconnectFromLink(link);
            throw e;
        }
    }
952577
@Override
    public Promise<Void> link(String link, String existing) {
        return adapter.toPromise(handler -> vertx.fileSystem().link(link, existing, handler));
    }
1321284
@Override
    public void addConnectionListener(SICoreConnectionListener listener)
                    throws SIConnectionDroppedException,
                    SIConnectionUnavailableException {

        checkValid();

        _delegateConnection.addConnectionListener(listener);

    }
259088
public void setLinkManager(LinkManager linkManager)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "setLinkManager", linkManager);
    
    _localisationManager.getTRMFacade().setLinkManager(linkManager);

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
       SibTr.exit(tc, "setLinkManager");
  }
860570
public void linkFromJSON(Model mo, Network net, JSONObject o) throws JSONConverterException {
        net.connect(requiredInt(o, "id"),
                readCapacity(o),
                getSwitch(net, requiredInt(o, SWITCH_LABEL)),
                physicalElementFromJSON(mo, net, (JSONObject) o.get("physicalElement"))
        );
    }
259466
public function linkToMany($model, $link): void
    {
        Relations::setRelations($this->model, $model, [$link]);
    }
120540
public void add(Mtp2 link) {
        // add link at the first empty place
        for (int i = 0; i < links.length; i++) {
            if (links[i] == null) {
                links[i] = link;
                break;
            }
        }
        count++;
        remap();
    }
1307942
public void drawLink(Link link) {
        List<Device> linkedDevices = link.getLinkedDevices();
        for (int i = 0; i<linkedDevices.size(); i++) {
            Device from = linkedDevices.get(i);
            for (int j = i+1 ; j<linkedDevices.size(); j++) {
                Device to = linkedDevices.get(j);
                Edge e = new Edge(from, to, link);
                links.addEdge(e);
            }
        }
    }
3018
public synchronized void connected(BluetoothSocket socket, BluetoothDevice
            device, final String socketType) {
        // Cancel the thread that completed the connection
        if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}

        // Cancel any thread currently running a connection
        if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}

        // Cancel the accept thread because we only want to tryConnect to one device
        if (mSecureAcceptThread != null) {
            mSecureAcceptThread.cancel();
            mSecureAcceptThread = null;
        }

        // Start the thread to manage the connection and perform transmissions
        mConnectedThread = new ConnectedThread(socket, socketType);
        mConnectedThread.start();

        // Send the name of the connected device back to the UI Activity
        Message msg = mHandler.obtainMessage(MESSAGE_DEVICE_NAME);
        mHandler.sendMessage(msg);

        setState(BluetoothService.STATE_CONNECTED);
    }
457138
public void setLink(Link link) {
		setHref(link.getHref());
		setHrefAbsolute(link.getHrefAbsolute());
		HttpParameters linkParams = link.getParams();
		if(linkParams != null) {
			for(Map.Entry<String,List<String>> entry : linkParams.getParameterMap().entrySet()) {
				String paramName = entry.getKey();
				for(String paramValue : entry.getValue()) {
					addParam(paramName, paramValue);
				}
			}
		}
		this.addLastModified = link.getAddLastModified();
		setHreflang(link.getHreflang());
		setRel(link.getRel());
		setType(link.getType());
		setMedia(link.getMedia());
		setTitle(link.getTitle());
	}
943643
protected void processLink(Row row)
   {
      Task predecessorTask = m_project.getTaskByUniqueID(row.getInteger("LINK_PRED_UID"));
      Task successorTask = m_project.getTaskByUniqueID(row.getInteger("LINK_SUCC_UID"));
      if (predecessorTask != null && successorTask != null)
      {
         RelationType type = RelationType.getInstance(row.getInt("LINK_TYPE"));
         TimeUnit durationUnits = MPDUtility.getDurationTimeUnits(row.getInt("LINK_LAG_FMT"));
         Duration duration = MPDUtility.getDuration(row.getDouble("LINK_LAG").doubleValue(), durationUnits);
         Relation relation = successorTask.addPredecessor(predecessorTask, type, duration);
         relation.setUniqueID(row.getInteger("LINK_UID"));
         m_eventManager.fireRelationReadEvent(relation);
      }
   }
1065531
private void connectIfNotDone(ZMQ.Socket socket, ZMQutils.ControlStructure controlStructure){

        traceZmqSubscription(controlStructure.eventName, true);
        //  Check if not already connected or forced (re connection)
        if (controlStructure.forceReconnection || !alreadyConnected(controlStructure.endPoint)) {
            ApiUtil.printTrace("Set socket buffer for HWM to " + controlStructure.hwm);

            //  Check if it ia a reconnection -> disconnect before connection
            if (controlStructure.forceReconnection && alreadyConnected(controlStructure.endPoint)) {
                try {
                    //  needs an un subscribe before disconnection
                    //socket.unsubscribe(controlStructure.eventName.getBytes());
                    socket.disconnect(controlStructure.endPoint);
                }
                catch (org.zeromq.ZMQException e) {
                    System.err.println(e.getMessage());
                }
            }

            //  Do the connection
            //System.out.println("Connect on " + controlStructure.endPoint);
            //System.out.println("        for " + controlStructure.eventName);
            socket.setHWM(controlStructure.hwm);
            socket.connect(controlStructure.endPoint);
            if (!alreadyConnected(controlStructure.endPoint)) {
                EventList eventList = new EventList();
                eventList.add(controlStructure.eventName);
                connectedMap.put(controlStructure.endPoint, eventList);
            }
            else {
                //  Add to event list if not done
                EventList eventList = connectedMap.get(controlStructure.endPoint);
                String  s = eventList.getEvent(controlStructure.eventName);
                if (s==null)
                    eventList.add(controlStructure.eventName);
            }
        }
        else {
            //  Add to event list if not done
            EventList eventList = connectedMap.get(controlStructure.endPoint);
            String  s = eventList.getEvent(controlStructure.eventName);
            if (s==null)
                eventList.add(controlStructure.eventName);
            ApiUtil.printTrace(
                    ((controlStructure.commandCode==ZMQutils.ZMQ_CONNECT_EVENT)? "Event" : "Heartbeat") +
                    " already connected to " + controlStructure.endPoint);
        }
    }
1174405
def connect(self, protocol=None):
        """"""
        self._link.enter_debug(STLink.Protocol.SWD)
        self._is_connected = True
552511
private final void _tryUnlink() {
        if (0 >= _cursorCount && _state == LOGICALLY_UNLINKED) {
            _previousLink._nextLink = _nextLink;
            _nextLink._previousLink = _previousLink;
            _previousLink = null;
            _nextLink = null;
            // Defect 240039
            //_parent = null;
            _state = PHYSICALLY_UNLINKED;
        }
    }
684182
def _attach(self, fcp, assigner_id, target_wwpn, target_lun,
                multipath, os_version, mount_point):
        
        LOG.info('Start to attach device to %s' % assigner_id)
        self.fcp_mgr.init_fcp(assigner_id)
        new = self.fcp_mgr.increase_fcp_usage(fcp, assigner_id)
        try:
            if new:
                self._dedicate_fcp(fcp, assigner_id)

            self._add_disk(fcp, assigner_id, target_wwpn, target_lun,
                           multipath, os_version, mount_point)
        except exception.SDKBaseException as err:
            errmsg = 'rollback attach because error:' + err.format_message()
            LOG.error(errmsg)
            connections = self.fcp_mgr.decrease_fcp_usage(fcp, assigner_id)
            # if connections less than 1, undedicate the device
            if not connections:
                with zvmutils.ignore_errors():
                    self._undedicate_fcp(fcp, assigner_id)
            raise exception.SDKBaseException(msg=errmsg)
        # TODO: other exceptions?

        LOG.info('Attaching device to %s is done.' % assigner_id)
419549
function (successCallback, errorCallback, deviceId) {

			// Find the requested device in our list of discovered devices
			var device = winble.deviceManager.getDeviceFromId(deviceId, "connectToDevice", errorCallback);
			if (device == null) {
				errorCallback(winble.DEVICE_NOT_FOUND);
				return;
			}

			// Save the success callback; we will need to call this whenever the connection status changes.
			if (device.connectSuccessCallback == null)
				device.connectSuccessCallback = successCallback;

			// Call the success callback if the device is connected, error callback if not
			if (device.isReachable && device.isConnected) {
				winble.logger.logDebug("connectToDevice", "Connection successful");
				var connectInfo = {
					"deviceHandle": device.handle,
					"state": 2 // 0 = Disconnected, 1 = Connecting, 2 = Connected, 3 = Disconnecting
				};
				device.connectSuccessCallback(connectInfo, { keepCallback: true });
			} else {
				winble.logger.logDebug("connectToDevice", "Connection failed");
				errorCallback(winble.DEVICE_NOT_CONNECTED);
			}
		}
1353797
public void connectDevices(Device device1, Device device2)
            throws ShanksException {
        this.connectDevice(device1);
        try {
            this.connectDevice(device2);
        } catch (ShanksException e) {
            this.disconnectDevice(device1);
            throw e;
        }
    }