Index: source/ariba/overlay/BaseOverlay.cpp
===================================================================
--- source/ariba/overlay/BaseOverlay.cpp	(revision 5870)
+++ source/ariba/overlay/BaseOverlay.cpp	(revision 5871)
@@ -137,13 +137,4 @@
 	}
 
-<<<<<<< .working
-	// get used next hop towards node
-	LinkDescriptor* rld = NULL;
-	NodeID relayNode = NodeID::UNSPECIFIED;
-	LinkID rlid = overlayInterface->getNextLinkId(id);
-	if ( relayNode.isUnspecified() && !rlid.isUnspecified() && rld == NULL ) {
-		// get descriptor of first hop
-		rld = getDescriptor(rlid);
-=======
 	// iterate over all links and check for time boundaries
 	vector<LinkDescriptor*> oldlinks;
@@ -153,17 +144,7 @@
 		if ( ld->relaying && difftime( now, ld->timeRelaying ) > 10)
 			ld->relaying = false;
->>>>>>> .merge-rechts.r5869
-
-<<<<<<< .working
-		// is first hop a relay path use local relay
-		if ( rld->relay ) relayNode = rld->localRelay;
-
-		// no-> a proper relay node has been found
-		else relayNode = rld->remoteNode;
-	}
-=======
+
 		// keep alives and not up? yes-> link connection request is stale!
 		if ( !ld->up && difftime( now, ld->keepAliveTime ) >= 2 ) {
->>>>>>> .merge-rechts.r5869
 
 			// increase counter
@@ -181,13 +162,4 @@
 		if (!ld->up) continue;
 
-<<<<<<< .working
-	// get descriptor
-	BOOST_FOREACH( LinkDescriptor* lp, links )
-		if (lp->remoteNode == relayNode &&
-		    lp->service == OverlayInterface::OVERLAY_SERVICE_ID &&
-		    lp->relay == false &&
-		    lp->up)
-			return lp;
-=======
 		// drop links that are dropped and not used as relay
 		if (ld->dropAfterRelaying && !ld->relaying && !ld->autolink) {
@@ -200,5 +172,5 @@
 			oldlinks.push_back( ld );
 			continue;
->>>>>>> .merge-rechts.r5869
+		}
 
 		// keep alives missed? yes->
@@ -536,4 +508,5 @@
 	}
 
+
 	//ovl.visShowNodeBubble ( ovlId, nodeId, "joining..." );
 	logging_info( "Starting to join spovnet " << id.toString() <<
@@ -543,5 +516,5 @@
 
 		// bootstrap against ourselfs
-		logging_info("joining spovnet locally");
+		logging_debug("joining spovnet locally");
 
 		overlayInterface->joinOverlay();
@@ -560,11 +533,9 @@
 
 		// bootstrap against another node
-		logging_info("joining spovnet remotely against " << bootstrapEp.toString());
+		logging_debug("joining spovnet remotely against " << bootstrapEp.toString());
 
 		const LinkID& lnk = bc->establishLink( bootstrapEp );
 		bootstrapLinks.push_back(lnk);
-
 		logging_info("join process initiated for " << id.toString() << "...");
-
 	}
 }
@@ -1227,11 +1198,5 @@
 		delete replyMsg;
 
-<<<<<<< .working
-					// inform all registered services of the event
-					BOOST_FOREACH( NodeListener* i, nodeListeners )
-						i->onJoinFailed( spovnetId );
-=======
 	} else {
->>>>>>> .merge-rechts.r5869
 
 		// this is not the first bootstrap, just join the additional node
@@ -1241,4 +1206,5 @@
 
 		delete replyMsg;
+
 	} // if( overlayInterface == NULL )
 
@@ -1247,6 +1213,4 @@
 
 
-<<<<<<< .working
-=======
 bool BaseOverlay::handleData( OverlayMsg* overlayMsg, LinkDescriptor* ld ) {
 	// get service
@@ -1255,5 +1219,4 @@
 		<< " on link " << overlayMsg->getDestinationLink().toString() );
 
->>>>>>> .merge-rechts.r5869
 	// delegate data message
 	getListener(service)->onMessage(
@@ -1266,19 +1229,7 @@
 }
 
-<<<<<<< .working
-=======
-
->>>>>>> .merge-rechts.r5869
+
 bool BaseOverlay::handleLinkUpdate( OverlayMsg* overlayMsg, LinkDescriptor* ld ) {
 
-<<<<<<< .working
-			//record bootstrap ep as good endpoint to join
-			overlayBootstrap.recordJoin( replyMsg->getBootstrapEndpoint() );
-
-			delete replyMsg;
-			ret = true;
-			break;
-		}
-=======
 	if( ld == NULL ) {
 		logging_warn( "received overlay update message for link for "
@@ -1287,5 +1238,4 @@
 	}
 	logging_info("Received type update message on link " << ld );
->>>>>>> .merge-rechts.r5869
 
 	// update our link mapping information for this link
@@ -1310,9 +1260,4 @@
 	}
 
-<<<<<<< .working
-			// delegate data message
-			listener->onMessage( overlayMsg,
-				overlayMsg->getSourceNode(), ld->overlayId );
-=======
 	// service registered? no-> error!
 	if( !communicationListeners.contains( ld->service ) ) {
@@ -1320,5 +1265,4 @@
 		return false;
 	}
->>>>>>> .merge-rechts.r5869
 
 	// default or no service registered?
@@ -1467,6 +1411,4 @@
 }
 
-<<<<<<< .working
-=======
 /// handle a keep-alive message for a link
 bool BaseOverlay::handleLinkAlive( OverlayMsg* overlayMsg, LinkDescriptor* ld ) {
@@ -1490,5 +1432,4 @@
 	logging_debug( "Received direct link replacement request" );
 
->>>>>>> .merge-rechts.r5869
 	/// get destination overlay link
 	LinkDescriptor* rld = getDescriptor( overlayMsg->getDestinationLink() );
@@ -1505,27 +1446,7 @@
 	rld->relayed = false;
 
-<<<<<<< .working
-					// mark incoming link as relay
-					if (ld!=NULL) ld->markAsRelay();
-
-					// am I the destination of this message? yes->
-					if (relayMsg->getDestNode() == nodeId ) {
-						// deliver relay message locally!
-						logging_debug("Relay message reached destination. Handling the message.");
-						handleMessage( relayMsg, relayMsg->getDestLink(), LinkID::UNSPECIFIED, remoteNode );
-						ret = true;
-						break;
-					}
-
-					// create route message
-					OverlayMsg _overMsg( *overlayMsg );
-					RelayMessage _relayMsg( *relayMsg );
-					_relayMsg.setType( RelayMessage::typeRoute );
-					_overMsg.encapsulate( &_relayMsg );
-=======
 	// mark used and alive!
 	rld->setAlive();
 	rld->setAutoUsed();
->>>>>>> .merge-rechts.r5869
 
 	// erase the original descriptor
@@ -1538,29 +1459,8 @@
 	logging_debug( "Handling message: " << message->toString());
 
-<<<<<<< .working
-					// mark incoming link as relay
-					if (ld!=NULL) ld->markAsRelay();
-
-					// am I the destination of this message? yes->
-					if (relayMsg->getDestNode() == nodeId ) {
-						// deliver relay message locally!
-						logging_debug("Relay message reached destination. Handling the message.");
-						handleMessage( relayMsg, relayMsg->getDestLink(), LinkID::UNSPECIFIED, remoteNode );
-						ret = true;
-						break;
-					}
-
-					// am I the relay for this message? yes->
-					if (relayMsg->getRelayNode() == nodeId ) {
-						logging_debug("I'm the relay for this message. Sending to destination.");
-						OverlayMsg _overMsg( *overlayMsg );
-						RelayMessage _relayMsg( *relayMsg );
-						_overMsg.encapsulate(&_relayMsg);
-=======
 	// decapsulate overlay message
 	OverlayMsg* overlayMsg =
 		const_cast<Message*>(message)->decapsulate<OverlayMsg>();
 	if( overlayMsg == NULL ) return false;
->>>>>>> .merge-rechts.r5869
 
 	// refresh relay information
@@ -1651,7 +1551,6 @@
 /// return the overlay neighbors
 vector<NodeID> BaseOverlay::getOverlayNeighbors(bool deep) const {
-
+	// the known nodes _can_ also include our node, so we remove ourself
 	vector<NodeID> nodes = overlayInterface->getKnownNodes(deep);
-	// the known nodes _can_ also include our node, so we remove ourself
 	vector<NodeID>::iterator i = find( nodes.begin(), nodes.end(), this->nodeId );
 	if( i != nodes.end() ) nodes.erase( i );
@@ -1688,88 +1587,6 @@
 
 void BaseOverlay::eventFunction() {
-<<<<<<< .working
-
-	// send keep-alive messages over established links
-	BOOST_FOREACH( LinkDescriptor* ld, links ) {
-		if (!ld->up) continue;
-		OverlayMsg overMsg( OverlayMsg::typeKeepAlive,
-			OverlayInterface::OVERLAY_SERVICE_ID, nodeId );
-		sendMessage( &overMsg, ld );
-	}
-
-	// iterate over all links and check for time boundaries
-	vector<LinkDescriptor*> oldlinks;
-	time_t now = time(NULL);
-	BOOST_FOREACH( LinkDescriptor* ld, links ) {
-		// remote used as relay flag
-		if ( ld->usedAsRelay && difftime( now, ld->timeUsedAsRelay ) > 10)
-			ld->usedAsRelay = false;
-
-		// keep alives and not up? yes-> link connection request is stale!
-		if ( !ld->up && difftime( now, ld->keepAliveTime ) >= 2 ) {
-
-			// increase counter
-			ld->keepAliveMissed++;
-
-			// missed more than four keep-alive messages (10 sec)? -> drop link
-			if (ld->keepAliveMissed > 4) {
-				logging_info( "Link connection request is stale, closing: " << ld );
-				oldlinks.push_back( ld );
-				continue;
-			}
-		}
-
-		if (!ld->up) continue;
-
-		// drop links that are dropped and not used as relay
-		if (ld->dropWhenRelaysLeft && !ld->usedAsRelay && !ld->autolink) {
-			oldlinks.push_back( ld );
-			continue;
-		}
-
-		// auto-link time exceeded?
-		if ( ld->autolink && difftime( now, ld->lastuse ) > 30 ) {
-			oldlinks.push_back( ld );
-			continue;
-		}
-
-		// keep alives missed? yes->
-		if ( difftime( now, ld->keepAliveTime ) > 2 ) {
-
-			// increase counter
-			ld->keepAliveMissed++;
-
-			// missed more than four keep-alive messages (4 sec)? -> drop link
-			if (ld->keepAliveMissed >= 8) {
-				logging_info( "Link is stale, closing: " << ld );
-				oldlinks.push_back( ld );
-				continue;
-			}
-		}
-	}
-
-	// drop links
-	BOOST_FOREACH( const LinkDescriptor* ld, oldlinks ) {
-/*
-		vector<LinkID>::iterator it = std::find(
-				bootstrapLinks.begin(), bootstrapLinks.end(), ld->communicationId);
-
-		if (!ld->communicationId.isUnspecified() && it != bootstrapLinks.end() ){
-			logging_info( "Not dropping initiator link: " << ld );
-			continue;
-		}
-*/
-		logging_info( "Link timed out. Dropping " << ld );
-		dropLink( ld->overlayId );
-	}
-
-	// show link state
-	counter++;
-	if (counter>=4) showLinkState();
-	if (counter>=4 || counter<0) counter = 0;
-=======
 	stabilizeRelays();
 	stabilizeLinks();
->>>>>>> .merge-rechts.r5869
 }
 
