Package org.aktin.broker.db
Class BrokerImpl
java.lang.Object
org.aktin.broker.db.BrokerImpl
- All Implemented Interfaces:
BrokerBackend,Broker
@Singleton public class BrokerImpl extends Object implements BrokerBackend, Broker
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceBrokerImpl.RequestInfoLoader -
Constructor Summary
Constructors Constructor Description BrokerImpl()BrokerImpl(DataSource brokerDB, Path dataDirectory) -
Method Summary
Modifier and Type Method Description PrincipalaccessPrincipal(AuthInfo auth)Add or retrieve the node principal.voidclearDataDirectory()voidclearRequestTargets(int requestId)intcreateRequest()intcreateRequest(String mediaType, Reader content)voiddeleteRequest(int id)List<Node>getAllNodes()protected intgetLastInsertId(Connection dbc)NodegetNode(int nodeId)DigestPathDataSourcegetNodeResource(int nodeId, String resourceId)ReadergetRequestDefinition(int requestId, String mediaType)RequestInfogetRequestInfo(int requestId)ReadergetRequestNodeStatusMessage(int requestId, int nodeId)int[]getRequestTargets(int requestId)List<String>getRequestTypes(int requestId)List<RequestInfo>listAllRequests()List<RequestStatusInfo>listRequestNodeStatus(Integer requestId)List<RequestInfo>listRequestsForNode(int nodeId)booleanmarkRequestDeletedForNode(int nodeId, int requestId)voidsetBrokerDB(DataSource brokerDB)voidsetDataDirectory(Path dataDir)voidsetRequestClosed(int requestId, Instant timestamp)voidsetRequestDefinition(int requestId, String mediaType, Reader content)voidsetRequestNodeStatus(int requestId, int nodeId, RequestStatus status, Instant timestamp)voidsetRequestNodeStatusMessage(int requestId, int nodeId, String mediaType, Reader message)voidsetRequestPublished(int requestId, Instant timestamp)voidsetRequestTargets(int requestId, int[] nodes)voidupdateNodeLastSeen(int[] nodeIds, long[] timestamps)voidupdateNodeResource(int nodeId, String resourceId, javax.ws.rs.core.MediaType mediaType, InputStream content)static intupdatePrincipalDN(DataSource ds, Map<String,String> mapNodeDN)Update the clientDN string for the nodes given in the provided map.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.aktin.broker.db.BrokerBackend
updateNodeLastSeen
-
Constructor Details
-
BrokerImpl
public BrokerImpl() -
BrokerImpl
- Throws:
IOException
-
-
Method Details
-
setBrokerDB
- Specified by:
setBrokerDBin interfaceBrokerBackend
-
setDataDirectory
-
clearDataDirectory
- Specified by:
clearDataDirectoryin interfaceBrokerBackend- Throws:
IOException
-
getAllNodes
- Specified by:
getAllNodesin interfaceBroker- Throws:
SQLException
-
getNode
- Specified by:
getNodein interfaceBroker- Throws:
SQLException
-
getLastInsertId
- Throws:
SQLException
-
createRequest
- Specified by:
createRequestin interfaceBroker- Throws:
SQLException
-
createRequest
- Specified by:
createRequestin interfaceBroker- Throws:
SQLException
-
setRequestDefinition
public void setRequestDefinition(int requestId, String mediaType, Reader content) throws SQLException- Specified by:
setRequestDefinitionin interfaceBroker- Throws:
SQLException
-
deleteRequest
- Specified by:
deleteRequestin interfaceBroker- Throws:
SQLException
-
listAllRequests
- Specified by:
listAllRequestsin interfaceBroker- Throws:
SQLException
-
getRequestTypes
- Specified by:
getRequestTypesin interfaceBroker- Throws:
SQLException
-
getRequestDefinition
public Reader getRequestDefinition(int requestId, String mediaType) throws SQLException, IOException- Specified by:
getRequestDefinitionin interfaceBroker- Throws:
SQLExceptionIOException
-
listRequestsForNode
- Specified by:
listRequestsForNodein interfaceBroker- Throws:
SQLException
-
getRequestInfo
- Specified by:
getRequestInfoin interfaceBroker- Throws:
SQLException
-
setRequestNodeStatus
public void setRequestNodeStatus(int requestId, int nodeId, RequestStatus status, Instant timestamp) throws SQLException- Specified by:
setRequestNodeStatusin interfaceBroker- Throws:
SQLException
-
setRequestNodeStatusMessage
public void setRequestNodeStatusMessage(int requestId, int nodeId, String mediaType, Reader message) throws SQLException- Specified by:
setRequestNodeStatusMessagein interfaceBroker- Throws:
SQLException
-
getRequestNodeStatusMessage
public Reader getRequestNodeStatusMessage(int requestId, int nodeId) throws SQLException, IOException- Specified by:
getRequestNodeStatusMessagein interfaceBroker- Throws:
SQLExceptionIOException
-
markRequestDeletedForNode
- Specified by:
markRequestDeletedForNodein interfaceBroker- Throws:
SQLException
-
listRequestNodeStatus
- Specified by:
listRequestNodeStatusin interfaceBroker- Throws:
SQLException
-
accessPrincipal
Description copied from interface:BrokerBackendAdd or retrieve the node principal. The node is identified by its key. The key can be any string value. It is used as primary identifier and should not change. For API-Key authentication, this can be the API key. For TLS client certificate authentication, this may be the certificate serial number. For external auth, a user id / login name can be used.- Specified by:
accessPrincipalin interfaceBrokerBackend- Parameters:
auth- authentication information- Returns:
- principal
- Throws:
SQLException- SQL error
-
setRequestPublished
- Specified by:
setRequestPublishedin interfaceBroker- Throws:
SQLException
-
setRequestClosed
- Specified by:
setRequestClosedin interfaceBroker- Throws:
SQLException
-
updateNodeLastSeen
- Specified by:
updateNodeLastSeenin interfaceBrokerBackend- Throws:
SQLException
-
setRequestTargets
- Specified by:
setRequestTargetsin interfaceBroker- Throws:
SQLException
-
getRequestTargets
- Specified by:
getRequestTargetsin interfaceBroker- Throws:
SQLException
-
clearRequestTargets
- Specified by:
clearRequestTargetsin interfaceBroker- Throws:
SQLException
-
updateNodeResource
public void updateNodeResource(int nodeId, String resourceId, javax.ws.rs.core.MediaType mediaType, InputStream content) throws IOException, SQLException- Specified by:
updateNodeResourcein interfaceBrokerBackend- Throws:
IOExceptionSQLException
-
getNodeResource
- Specified by:
getNodeResourcein interfaceBroker- Throws:
SQLException
-
updatePrincipalDN
public static int updatePrincipalDN(DataSource ds, Map<String,String> mapNodeDN) throws SQLExceptionUpdate the clientDN string for the nodes given in the provided map.- Parameters:
ds- data sourcemapNodeDN- Map of node keys pointing to clientDN strings- Returns:
- number of updated nodes
- Throws:
SQLException- SQL error
-