/** * Connects this member to the cluster using the given <code>loadFactor</code>. The <code> * loadFactor</code> defines the (approximate) relative load that this member will receive. * * <p>A good default value is 100, which will give this member 100 nodes on the distributed hash * ring. Giving all members (proportionally) lower values will result in a less evenly distributed * hash. * * @param loadFactor The load factor for this node. * @throws ConnectionFailedException when an error occurs while connecting */ public synchronized void connect(int loadFactor) throws ConnectionFailedException { this.currentLoadFactor = loadFactor; Assert.isTrue(loadFactor >= 0, "Load Factor must be a positive integer value."); Assert.isTrue( channel.getReceiver() == null || channel.getReceiver() == messageReceiver, "The given channel already has a receiver configured. " + "Has the channel been reused with other Connectors?"); try { channel.setReceiver(messageReceiver); if (channel.isConnected() && !clusterName.equals(channel.getClusterName())) { throw new AxonConfigurationException( "The Channel that has been configured with this JGroupsConnector " + "is already connected to another cluster."); } else if (channel.isConnected()) { // we need to fetch state now that we have attached our MessageReceiver channel.getState(null, 10000); } else { // we need to connect. This will automatically fetch state as well. channel.connect(clusterName, null, 10000); } updateMembership(); } catch (Exception e) { joinedCondition.markJoined(false); channel.disconnect(); throw new ConnectionFailedException("Failed to connect to JGroupsConnectorFactoryBean", e); } }
@Override public PhysicalOperator visitJoin(Join join, Object value) throws OptimizerException { PhysicalOperator leftOp = join.getLeft().accept(this, value); List<OrderDef> leftOrderDefs = Lists.newArrayList(); for (JoinCondition jc : join.getConditions()) { leftOrderDefs.add(new OrderDef(Direction.ASC, jc.getLeft())); } leftOp = new Sort(leftOp, leftOrderDefs, false); leftOp = new SelectionVectorRemover(leftOp); PhysicalOperator rightOp = join.getRight().accept(this, value); List<OrderDef> rightOrderDefs = Lists.newArrayList(); for (JoinCondition jc : join.getConditions()) { rightOrderDefs.add(new OrderDef(Direction.ASC, jc.getRight())); } rightOp = new Sort(rightOp, rightOrderDefs, false); rightOp = new SelectionVectorRemover(rightOp); MergeJoinPOP mjp = new MergeJoinPOP( leftOp, rightOp, Arrays.asList(join.getConditions()), join.getJointType()); return new SelectionVectorRemover(mjp); }
private EntityFilter<Insight> buildFilter(ServletRequest request) { Map<String, String> params = getPredefinedParams(request); return addNonPredefinedParams(request) .withCondition( Condition.builder() .comparison(Comparison.EQUAL) .field("evaluator") .value(params.get("eval") != null ? Long.valueOf(params.get("eval")) : null) .build()) .withCondition( Condition.builder() .comparison(Comparison.BETWEEN) .field("date") .value( new HashMap<String, LocalDateTime>() { { put( EntityFilter.LOWER_LIMIT_PARAM_NAME, parseDateOrDateTime( Optional.ofNullable(params.get("from")) .orElseGet(LocalDateTime.MIN::toString))); put( EntityFilter.UPPER_LIMIT_PARAM_NAME, parseDateOrDateTime( Optional.ofNullable(params.get("to")) .orElseGet(LocalDateTime.MAX::toString))); } }) .build()) .withJoinCondition( JoinCondition.builder() .comparison(Comparison.EQUAL) .joinClass(InsightEvaluator.class) .joinAttributeName("evaluator") .field("questionId") .value(params.get("question") != null ? Long.valueOf(params.get("question")) : null) .build()) .build(); }
/** * this method blocks until this member has successfully joined the other members, until the * thread is interrupted, when the given number of milliseconds have passed, or when joining has * failed. * * @param timeout The amount of time to wait for the connection to complete * @param timeUnit The time unit of the timeout * @return <code>true</code> if the member successfully joined, otherwise <code>false</code>. * @throws InterruptedException when the thread is interrupted while joining */ public boolean awaitJoined(long timeout, TimeUnit timeUnit) throws InterruptedException { joinedCondition.await(timeout, timeUnit); return joinedCondition.isJoined(); }
/** * this method blocks until this member has successfully joined the other members, until the * thread is interrupted, or when joining has failed. * * @return <code>true</code> if the member successfully joined, otherwise <code>false</code>. * @throws InterruptedException when the thread is interrupted while joining */ public boolean awaitJoined() throws InterruptedException { joinedCondition.await(); return joinedCondition.isJoined(); }