src/com/vehiclerental/logicLayer/implementations/VehicleServiceImpl.java
/**
     * Broadcasts the available vehicle search to all the other branch nodes and returns the combined results
     *
     * @param searchCriteriaContract the search criteria details
     * @param currentUserId the ID of the requesting user
     * @return the list of the combined available vehicles
     * @throws ClusterCommunicatorException if one of the dates is invalid
     */
Broadcasts the available vehicle search to all the other branch nodes and returns the combined results
@param searchCriteriaContract the search criteria details
@param currentUserId the ID of the requesting user
@return the list of the combined available vehicles
@throws ClusterCommunicatorException if one of the dates is invalid
Broadcasts the available vehicle search to all the other branch nodes and returns the combined results @param searchCriteriaContract the search criteria details @param currentUserId the ID of the requesting user @return the list of the combined available vehicles @throws ClusterCommunicatorException if one of the dates is invalid
@Override
    public List<BookingSearchResultContract> broadcastSearchAvailableVehicles(SearchAvailableVehiclesRequestContract searchCriteriaContract, int currentUserId) throws ClusterCommunicatorException {
        List<BookingSearchResultContract> responseContracts = new ArrayList<BookingSearchResultContract>();
        BranchRequestMessage<SearchAvailableVehiclesRequestContract> branchRequestMessage = new BranchRequestMessage<SearchAvailableVehiclesRequestContract>();
        branchRequestMessage.object = searchCriteriaContract;
        branchRequestMessage.operationCode = OperationCodes.CLUSTER_SEARCH_AVAIL_VEHICLES_BROADCAST;
        branchRequestMessage.userId = currentUserId;
        for (Branch branch:NodeConfiguration.Current.branches.values()) {
            if (branch.getClusterId() != NodeConfiguration.Current.nodeBranch.getClusterId()) {
                NodeConfiguration.Current.clusterCommunicator.sendObject(
                        branch.getClusterId(),
                        OperationCodes.CLUSTER_SEARCH_AVAIL_VEHICLES_BROADCAST,
                        SerializationUtils.serialize(branchRequestMessage));
                ClusterCommunicationObject<String> rawMpiResponse = NodeConfiguration.Current.clusterCommunicator.receiveObject(
                        branch.getClusterId(),
                        OperationCodes.CLUSTER_SEARCH_AVAIL_VEHICLES_BROADCAST,
                        String.class);
                Type jsonType = new TypeToken<BranchResponseMessage<List<BookingSearchResultContract>>>() {}.getType();
                BranchResponseMessage<List<BookingSearchResultContract>> clusterVehiclesResponse = SerializationUtils.deserialize(rawMpiResponse.object, jsonType);
                if (clusterVehiclesResponse.Status == 200) {
                    responseContracts.addAll(clusterVehiclesResponse.Object);
                }
            }
        }
        return responseContracts;
    }
@ Override public List < BookingSearchResultContract > broadcastSearchAvailableVehicles ( SearchAvailableVehiclesRequestContract searchCriteriaContract , int currentUserId ) throws ClusterCommunicatorException { List < BookingSearchResultContract > responseContracts = new ArrayList < BookingSearchResultContract > ( ) ; BranchRequestMessage < SearchAvailableVehiclesRequestContract > branchRequestMessage = new BranchRequestMessage < SearchAvailableVehiclesRequestContract > ( ) ; branchRequestMessage . object = searchCriteriaContract ; branchRequestMessage . operationCode = OperationCodes . CLUSTER_SEARCH_AVAIL_VEHICLES_BROADCAST ; branchRequestMessage . userId = currentUserId ; for ( Branch branch : NodeConfiguration . Current . branches . values ( ) ) { if ( branch . getClusterId ( ) != NodeConfiguration . Current . nodeBranch . getClusterId ( ) ) { NodeConfiguration . Current . clusterCommunicator . sendObject ( branch . getClusterId ( ) , OperationCodes . CLUSTER_SEARCH_AVAIL_VEHICLES_BROADCAST , SerializationUtils . serialize ( branchRequestMessage ) ) ; ClusterCommunicationObject < String > rawMpiResponse = NodeConfiguration . Current . clusterCommunicator . receiveObject ( branch . getClusterId ( ) , OperationCodes . CLUSTER_SEARCH_AVAIL_VEHICLES_BROADCAST , String . class ) ; Type jsonType = new TypeToken < BranchResponseMessage < List < BookingSearchResultContract > > > ( ) { } . getType ( ) ; BranchResponseMessage < List < BookingSearchResultContract > > clusterVehiclesResponse = SerializationUtils . deserialize ( rawMpiResponse . object , jsonType ) ; if ( clusterVehiclesResponse . Status == 200 ) { responseContracts . addAll ( clusterVehiclesResponse . Object ) ; } } } return responseContracts ; }
Broadcasts the available vehicle search to all the other branch nodes and returns the combined results
 @param searchCriteriaContract the search criteria details
 @param currentUserId the ID of the requesting user
 @return the list of the combined available vehicles
 @throws ClusterCommunicatorException if one of the dates is invalid
Broadcasts the available vehicle search to all the other branch nodes and returns the combined results @param searchCriteriaContract the search criteria details @param currentUserId the ID of the requesting user @return the list of the combined available vehicles @throws ClusterCommunicatorException if one of the dates is invalid
//Contact every other branch one by one //Parse cluster response