Skip to content

Commit

Permalink
Ctrl: do not connect to Ctrl or Aux nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ghernadi committed Sep 3, 2018
1 parent fd2df54 commit be94383
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.linbit.linstor.LinStorRuntimeException;
import com.linbit.linstor.NetInterface;
import com.linbit.linstor.NetInterface.EncryptionType;
import com.linbit.linstor.Node.NodeType;
import com.linbit.linstor.Node;
import com.linbit.linstor.annotation.SatelliteConnectorContext;
import com.linbit.linstor.logging.ErrorReporter;
Expand Down Expand Up @@ -62,59 +63,67 @@ public void startConnecting(Node node, AccessContext accCtx)
{
try
{
NetInterface stltConn = node.getSatelliteConnection(accCtx);
if (stltConn != null)
NodeType nodeType = node.getNodeType(accCtx);
if (nodeType.equals(NodeType.SATELLITE) || nodeType.equals(NodeType.COMBINED))
{
EncryptionType type = stltConn.getStltConnEncryptionType(accCtx);
String serviceType;
switch (type)
NetInterface stltConn = node.getSatelliteConnection(accCtx);
if (stltConn != null)
{
case PLAIN:
serviceType = ControllerNetComInitializer.PROPSCON_KEY_DEFAULT_PLAIN_CON_SVC;
break;
case SSL:
serviceType = ControllerNetComInitializer.PROPSCON_KEY_DEFAULT_SSL_CON_SVC;
break;
default:
throw new ImplementationError(
"Unhandled default case for EncryptionType",
null
EncryptionType type = stltConn.getStltConnEncryptionType(accCtx);
String serviceType;
switch (type)
{
case PLAIN:
serviceType = ControllerNetComInitializer.PROPSCON_KEY_DEFAULT_PLAIN_CON_SVC;
break;
case SSL:
serviceType = ControllerNetComInitializer.PROPSCON_KEY_DEFAULT_SSL_CON_SVC;
break;
default:
throw new ImplementationError(
"Unhandled default case for EncryptionType",
null
);
}
ServiceName dfltConSvcName;
try
{
dfltConSvcName = new ServiceName(
ctrlConf.getProp(serviceType)
);
}
ServiceName dfltConSvcName;
try
{
dfltConSvcName = new ServiceName(
ctrlConf.getProp(serviceType)
);
}
catch (InvalidNameException invalidNameExc)
{
throw new LinStorRuntimeException(
"The ServiceName of the default TCP connector is not valid",
invalidNameExc
);
}
TcpConnector tcpConnector = netComContainer.getNetComConnector(dfltConSvcName);
}
catch (InvalidNameException invalidNameExc)
{
throw new LinStorRuntimeException(
"The ServiceName of the default TCP connector is not valid",
invalidNameExc
);
}
TcpConnector tcpConnector = netComContainer.getNetComConnector(dfltConSvcName);

if (tcpConnector != null)
{
connectSatellite(
new InetSocketAddress(
stltConn.getAddress(accCtx).getAddress(),
stltConn.getStltConnPort(accCtx).value
),
tcpConnector,
node
);
}
else
{
throw new LinStorRuntimeException(
"Attempt to establish a " + type + " connection without a proper connector defined"
);
if (tcpConnector != null)
{
connectSatellite(
new InetSocketAddress(
stltConn.getAddress(accCtx).getAddress(),
stltConn.getStltConnPort(accCtx).value
),
tcpConnector,
node
);
}
else
{
throw new LinStorRuntimeException(
"Attempt to establish a " + type + " connection without a proper connector defined"
);
}
}
}
else
{
errorReporter.logDebug("Not connecting to " + nodeType.name() + " node: '" + node.getName().displayValue + "'");
}
}
catch (AccessDeniedException | InvalidKeyException exc)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,7 @@ public ApiCallRc createNode(
responseConverter.addWithOp(responses, context,
ApiSuccessUtils.defaultRegisteredEntry(node.getUuid(), getNodeDescriptionInline(node)));

if (type.equals(NodeType.SATELLITE) || type.equals(NodeType.COMBINED))
{
satelliteConnector.startConnecting(node, peerAccCtx.get());
}
satelliteConnector.startConnecting(node, peerAccCtx.get());
}
}
catch (Exception | ImplementationError exc)
Expand Down

0 comments on commit be94383

Please sign in to comment.