• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java View类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jgroups.View的典型用法代码示例。如果您正苦于以下问题:Java View类的具体用法?Java View怎么用?Java View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



View类属于org.jgroups包,在下文中一共展示了View类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addListener

import org.jgroups.View; //导入依赖的package包/类
public void addListener(@NotNull final JgroupsViewListener viewListener) {
    requireNonNull(viewListener);
    log.debug("Adding view listener {}...", viewListener);

    synchronized (viewListeners) {
        if (viewListeners.containsKey(viewListener)) {
            throw new IllegalStateException("View listener is already registered.");
        }
    }

    View initialView = jChannel.view();
    viewListener.initialView(initialView.getMembers());

    synchronized (viewListeners) {
        viewListeners.put(viewListener, initialView);
    }
}
 
开发者ID:florentw,项目名称:bench,代码行数:18,代码来源:JgroupsViewMultiplexer.java


示例2: viewUpdate

import org.jgroups.View; //导入依赖的package包/类
public void viewUpdate(final View newView) {
    requireNonNull(newView);
    log.debug("Processing view update {}...", newView);

    Map<JgroupsViewListener, Address[][]> diffs = new HashMap<>();

    synchronized (viewListeners) {
        viewListeners.forEach((viewListener, currentView) -> {
            Address[][] diff = View.diff(currentView, newView);
            viewListeners.put(viewListener, newView);
            diffs.put(viewListener, diff);
        });
    }

    diffs.forEach((viewListener, diff) -> {
        for (Address joined : diff[0]) {
            viewListener.memberJoined(joined);
        }
        for (Address left : diff[1]) {
            viewListener.memberLeft(left);
        }
    });
}
 
开发者ID:florentw,项目名称:bench,代码行数:24,代码来源:JgroupsViewMultiplexer.java


示例3: handleView

import org.jgroups.View; //导入依赖的package包/类
protected void handleView(View new_view, View old_view, boolean coord_changed) {
    if(is_coord) {
        if(clear_table_on_view_change)
            clearTable();
        else if(old_view != null && new_view != null) {
            Address[][] diff=View.diff(old_view, new_view);
            Address[] left_mbrs=diff[1];
            for(Address left_mbr : left_mbrs)
                if(left_mbr != null && !new_view.containsMember(left_mbr))
                    remove(left_mbr);
        }
    }
    if(coord_changed || clear_table_on_view_change)
        writeOwnInformation(); // write immediately
    if(info_writer_max_writes_after_view > 0)
        startInfoWriter(); // and / or write in the background
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:18,代码来源:UniTimeClusterDiscovery.java


示例4: installView

import org.jgroups.View; //导入依赖的package包/类
@Override
public void installView(NetView v) {
  this.view = v;

  if (this.jgAddress.getVmViewId() < 0) {
    this.jgAddress.setVmViewId(this.localAddress.getVmViewId());
  }
  List<JGAddress> mbrs = new ArrayList<>(v.size());
  mbrs.addAll(v.getMembers().stream().map(JGAddress::new).collect(Collectors.toList()));
  ViewId vid = new ViewId(new JGAddress(v.getCoordinator()), v.getViewId());
  View jgv = new View(vid, new ArrayList<>(mbrs));
  logger.trace("installing JGroups view: {}", jgv);
  this.myChannel.down(new Event(Event.VIEW_CHANGE, jgv));

  addressesWithIoExceptionsProcessed.clear();
  if (encrypt != null) {
    encrypt.installView(v);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:20,代码来源:JGroupsMessenger.java


示例5: viewAccepted

import org.jgroups.View; //导入依赖的package包/类
@Override
public void viewAccepted(View view) {
    if (endpoint.isEnableViewMessages()) {
        Exchange exchange = endpoint.createExchange(view);
        try {
            LOG.debug("Processing view: {}", view);
            processor.process(exchange, new AsyncCallback() {
                @Override
                public void done(boolean doneSync) {
                    // noop
                }
            });
        } catch (Exception e) {
            throw new JGroupsException("Error in consumer while dispatching exchange containing view " + view, e);
        }
    } else {
        LOG.debug("Option enableViewMessages is set to false. Skipping processing of the view: {}", view);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:CamelJGroupsReceiver.java


示例6: dropNonCoordinatorViews

import org.jgroups.View; //导入依赖的package包/类
/**
 * Creates predicate rejecting messages that are instances of {@code org.jgroups.View}, but have not been received
 * by the coordinator JGroups node. This filter is useful for keeping only view messages indicating that receiving
 * endpoint is a master node.
 *
 * @return predicate filtering out non-coordinator view messages.
 */
public static Predicate dropNonCoordinatorViews() {
    return new Predicate() {
        @Override
        public boolean matches(Exchange exchange) {
            Object body = exchange.getIn().getBody();
            LOG.debug("Filtering message {}.", body);
            if (body instanceof View) {
                View view = (View) body;
                Address coordinatorNodeAddress =  view.getMembers().get(COORDINATOR_NODE_INDEX);
                Address channelAddress = exchange.getIn().getHeader(HEADER_JGROUPS_CHANNEL_ADDRESS, Address.class);
                LOG.debug("Comparing endpoint channel address {} against the coordinator node address {}.",
                        channelAddress, coordinatorNodeAddress);
                return channelAddress.equals(coordinatorNodeAddress);
            }
            LOG.debug("Body {} is not an instance of org.jgroups.View . Skipping filter.", body);
            return false;
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:JGroupsFilters.java


示例7: start

import org.jgroups.View; //导入依赖的package包/类
public void start() throws Exception {
    String props="udp.xml";

    channel=new JChannel(props);

    channel.setReceiver(new ReceiverAdapter() {
        public void viewAccepted(View view) {
            setInternalState(view.getMembers());
        }

        public void setInternalState(java.util.List<Address> mbrs) {
            members.clear();
            for(Address mbr : mbrs)
                addNode(mbr);
            coordinator=mbrs.size() <= 1 || (mbrs.size() > 1 && mbrs.iterator().next().equals(my_addr));
            repaint();
        }
    });
    channel.connect(channel_name);
    my_addr=channel.getAddress();
    if(my_addr != null)
        setTitle(my_addr.toString());
    pack();
    setVisible(true);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:26,代码来源:Topology.java


示例8: handleView

import org.jgroups.View; //导入依赖的package包/类
protected void handleView(View new_view, View old_view, boolean coord_changed) {
    if(is_coord) {
        if(clear_table_on_view_change)
            clearTable();
        else if(old_view != null && new_view != null) {
            Address[][] diff=View.diff(old_view, new_view);
            Address[] left_mbrs=diff[1];
            for(Address left_mbr : left_mbrs)
                if(left_mbr != null && !new_view.containsMember(left_mbr))
                    remove(cluster_name, left_mbr);
        }
    }
    if(coord_changed || clear_table_on_view_change)
        writeOwnInformation(true); // write immediately
    if(info_writer_max_writes_after_view > 0)
        startInfoWriter(); // and / or write in the background
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:18,代码来源:JDBC_PING.java


示例9: readFrom

import org.jgroups.View; //导入依赖的package包/类
public void readFrom(DataInput in) throws Exception {
    byte flags=in.readByte();

    // 1. view
    if((flags & VIEW_PRESENT) == VIEW_PRESENT) {
        view=new View();
        view.readFrom(in);
    }

    // 2. digest
    if((flags & DIGEST_PRESENT) == DIGEST_PRESENT) {
        digest=new Digest(view.getMembersRaw());
        digest.readFrom(in, false);
    }

    // 3. fail_reason
    if((flags & FAIL_REASON_PRESENT) == FAIL_REASON_PRESENT)
        fail_reason=in.readUTF();
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:20,代码来源:JoinRsp.java


示例10: down

import org.jgroups.View; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Object down(Event evt) {
    switch(evt.getType()) {
        case Event.MSG:
            Message msg=(Message)evt.getArg();
            if(msg.isFlagSet(Message.Flag.NO_FC))
                break;
            int length=msg.getLength();
            if(length == 0)
                break;
            return handleDownMessage(evt, msg, length);
        case Event.CONFIG:
            handleConfigEvent((Map<String,Object>)evt.getArg()); 
            break;
        case Event.VIEW_CHANGE:
            handleViewChange(((View)evt.getArg()).getMembers());
            break;
    }
    return down_prot.down(evt); // this could potentially use the lower protocol's thread which may block
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:21,代码来源:FC.java


示例11: down

import org.jgroups.View; //导入依赖的package包/类
public Object down(Event evt) {
    switch(evt.getType()) {
        case Event.SET_LOCAL_ADDRESS:
            local_addr=(Address)evt.getArg();
            break;
        case Event.VIEW_CHANGE:
            handleView((View)evt.getArg());
            break;
    }

    if(num_event_handlers > 0) {
        for(EventHandler handler: event_handlers) {
            try {
                handler.down(evt);
            }
            catch(Throwable t) {
                log.error("event handler failed handling down event", t);
            }
        }
    }

    return down_prot.down(evt);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:24,代码来源:SUPERVISOR.java


示例12: up

import org.jgroups.View; //导入依赖的package包/类
public Object up(Event evt) {
    switch(evt.getType()) {
        case Event.VIEW_CHANGE:
            handleView((View)evt.getArg());
            break;
    }
    if(num_event_handlers > 0) {
        for(EventHandler handler: event_handlers) {
            try {
                handler.up(evt);
            }
            catch(Throwable t) {
                log.error("event handler failed handling up event", t);
            }
        }
    }
    return up_prot.up(evt);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:19,代码来源:SUPERVISOR.java


示例13: down

import org.jgroups.View; //导入依赖的package包/类
/**
 * Fragment a packet if larger than frag_size (add a header). Otherwise just pass down. Only
 * add a header if framentation is needed !
 */
public Object down(Event evt) {
    switch(evt.getType()) {

        case Event.MSG:
            Message msg=(Message)evt.getArg();
            long size=msg.size();
            num_sent_msgs++;
            if(size > frag_size) {
                if(log.isTraceEnabled()) {
                    StringBuilder sb=new StringBuilder("message size is ");
                    sb.append(size).append(", will fragment (frag_size=").append(frag_size).append(')');
                    log.trace(sb.toString());
                }
                fragment(msg, size);  // Fragment and pass down
                return null;
            }
            break;

        case Event.VIEW_CHANGE:
            handleViewChange((View)evt.getArg());
            break;
    }

    return down_prot.down(evt);  // Pass on to the layer below us
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:30,代码来源:FRAG.java


示例14: up

import org.jgroups.View; //导入依赖的package包/类
/**
 * If event is a message, if it is fragmented, re-assemble fragments into big message and pass up the stack.
 */
public Object up(Event evt) {
    switch(evt.getType()) {
        case Event.MSG:
            Message msg=(Message)evt.getArg();
            FragHeader hdr=(FragHeader)msg.getHeader(this.id);
            if(hdr != null) { // needs to be defragmented
                Message assembled_msg=unfragment(msg, hdr);
                if(assembled_msg != null)
                    up_prot.up(new Event(Event.MSG, assembled_msg));
                return null;
            }
            else {
                num_received_msgs++;
            }
            break;

        case Event.VIEW_CHANGE:
            handleViewChange((View)evt.getArg());
            break;
    }

    return up_prot.up(evt); // Pass up to the layer above us by default
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:27,代码来源:FRAG.java


示例15: down

import org.jgroups.View; //导入依赖的package包/类
/**
 * Fragment a packet if larger than frag_size (add a header). Otherwise just pass down. Only
 * add a header if fragmentation is needed !
 */
public Object down(Event evt) {
    switch(evt.getType()) {

        case Event.MSG:
            Message msg=(Message)evt.getArg();
            long size=msg.getLength();
            if(size > frag_size) {
                fragment(msg);  // Fragment and pass down
                return null;
            }
            break;

        case Event.VIEW_CHANGE:
            handleViewChange((View)evt.getArg());
            break;

        case Event.SET_LOCAL_ADDRESS:
            local_addr=(Address)evt.getArg();
            break;
    }

    return down_prot.down(evt);  // Pass on to the layer below us
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:28,代码来源:FRAG2.java


示例16: up

import org.jgroups.View; //导入依赖的package包/类
/**
 * If event is a message, if it is fragmented, re-assemble fragments into big message and pass up the stack.
 */
public Object up(Event evt) {
    switch(evt.getType()) {

        case Event.MSG:
            Message msg=(Message)evt.getArg();
            FragHeader hdr=(FragHeader)msg.getHeader(this.id);
            if(hdr != null) { // needs to be defragmented
                Message assembled_msg=unfragment(msg, hdr);
                if(assembled_msg != null) {
                    if(log.isTraceEnabled()) log.trace("%s: assembled_msg is %s", local_addr, assembled_msg);
                    assembled_msg.setSrc(msg.getSrc()); // needed ? YES, because fragments have a null src !!
                    up_prot.up(new Event(Event.MSG, assembled_msg));
                }
                return null;
            }
            break;

        case Event.VIEW_CHANGE:
            handleViewChange((View)evt.getArg());
            break;
    }

    return up_prot.up(evt); // Pass up to the layer above us by default
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:28,代码来源:FRAG2.java


示例17: handleView

import org.jgroups.View; //导入依赖的package包/类
protected void handleView(View new_view, View old_view, boolean coord_changed) {
    if(is_coord) {
        if(coord_changed) {
            if(remove_all_files_on_view_change)
                removeAll(cluster_name);
            else if(remove_old_coords_on_view_change) {
                Address old_coord=old_view != null? old_view.getCreator() : null;
                if(old_coord != null)
                    remove(cluster_name, old_coord);
            }
        }
        if(coord_changed || View.diff(old_view, new_view)[1].length > 0) {
            writeAll();
            if(remove_all_files_on_view_change || remove_old_coords_on_view_change)
                startInfoWriter();
        }
    }
    else if(coord_changed) // I'm no longer the coordinator
        remove(cluster_name, local_addr);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:21,代码来源:FILE_PING.java


示例18: viewAccepted

import org.jgroups.View; //导入依赖的package包/类
public void viewAccepted(View new_view) {
    nodes.clear();
    for(Address node: new_view.getMembers()) {
        int hash=Math.abs(node.hashCode() & (HASH_SPACE - 1));
        for(int i=hash; i < hash + HASH_SPACE; i++) {
            short new_index=(short)(i & (HASH_SPACE - 1));
            if(!nodes.containsKey(new_index)) {
                nodes.put(new_index, node);
                break;
            }
        }
    }

    if(log.isTraceEnabled()) {
        StringBuilder sb=new StringBuilder("node mappings:\n");
        for(Map.Entry<Short,Address> entry: nodes.entrySet()) {
            sb.append(entry.getKey() + ": " + entry.getValue()).append("\n");
        }
        log.trace(sb);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:22,代码来源:PartitionedHashMap.java


示例19: viewAccepted

import org.jgroups.View; //导入依赖的package包/类
public void viewAccepted(final View new_view) {
    final List<Address> old_nodes=this.view != null? new ArrayList<>(this.view.getMembers()) : null;

    this.view=new_view;
    if(log.isDebugEnabled())
        log.debug("new view: " + new_view);

    if(hash_function != null)
        hash_function.installNodes(new_view.getMembers());

    for(MembershipListener l: membership_listeners)
        l.viewAccepted(new_view);

    if(old_nodes != null) {
        timer.schedule(new Runnable() {
            public void run() {
                rebalance(old_nodes, new ArrayList<>(new_view.getMembers()));
            }
        }, 100, TimeUnit.MILLISECONDS);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:22,代码来源:ReplCache.java


示例20: testNonConflictingMerge

import org.jgroups.View; //导入依赖的package包/类
public void testNonConflictingMerge() {
    Address ip1=Util.createRandomAddress("x"), ip2=Util.createRandomAddress("y");
    View tmp_view=View.create(a1,1,a1,a2,a3,ip1,ip2);
    MutableDigest cons_d=new MutableDigest(tmp_view.getMembersRaw());

    cons_d.set(ip1,10,10);
    cons_d.set(ip2,20,20);
    cons_d.merge(d);

    Assert.assertEquals(cons_d.capacity(), 5);

    Assert.assertEquals(cons_d.get(ip1)[0], 10);
    Assert.assertEquals(cons_d.get(ip2)[0], 20);
    Assert.assertEquals(cons_d.get(a1)[0], 500);
    Assert.assertEquals(cons_d.get(a2)[0], 26);
    Assert.assertEquals(cons_d.get(a3)[0], 25);

    Assert.assertEquals(cons_d.get(ip1)[1], 10);
    Assert.assertEquals(cons_d.get(ip2)[1], 20);
    Assert.assertEquals(cons_d.get(a1)[1], 501);
    Assert.assertEquals(cons_d.get(a2)[1], 26);
    Assert.assertEquals(cons_d.get(a3)[1], 33);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:24,代码来源:DigestTest.java



注:本文中的org.jgroups.View类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RetrievalMethod类代码示例发布时间:2022-05-21
下一篇:
Java XulDomContainer类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap