⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bamboosubsystemimpl.ucjava

📁 High performance DB query
💻 UCJAVA
字号:
/* * @(#)$Id: BambooSubsystemImpl.ucjava,v 1.14 2005/04/27 20:56:38 huebsch Exp $ * * Copyright (c) 2001-2004 Regents of the University of California. * All rights reserved. * * This file is distributed under the terms in the attached BERKELEY-LICENSE * file. If you do not find these files, copies can be found by writing to: * Computer Science Division, Database Group, Universite of California, * 617 Soda Hall #1776, Berkeley, CA 94720-1776. Attention: Berkeley License * * Copyright (c) 2003-2004 Intel Corporation. All rights reserved. * * This file is distributed under the terms in the attached INTEL-LICENSE file. * If you do not find these files, copies can be found by writing to: * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, * Berkeley, CA, 94704.  Attention:  Intel License Inquiry. */package overlay.location.bamboo;import bamboo.router.RouterCallbackInterface;import bamboo.api.BambooNeighborInfo;import bamboo.router.Router;import bamboo.util.GuidTools;import java.math.BigInteger;import java.net.InetAddress;import org.apache.log4j.Logger;import ostore.util.NodeId;import ostore.util.QuickSerializable;import services.network.Payload;import services.Output;import util.BitID;import util.logging.LogMessage;/** * Class BambooSubsystemImpl * */public class BambooSubsystemImpl        implements BambooSubsystem, RouterCallbackInterface.LeafSetChangedCB,                   RouterCallbackInterface.RoutingTableChangedCB,                   RouterCallbackInterface.RouteUpcallCB,                   RouterCallbackInterface.RouteDeliverCB,                   RouterCallbackInterface.ApplicationRegisteredCB {    private static Logger logger = Logger.getLogger(BambooSubsystemImpl.class);    private Bamboo receipent;    private BigInteger myID, modulus;    private BitID myBitID;    private boolean routerInitialized;    private RouterCallbackInterface router;    /**     * Constructor BambooSubsystemImpl     */    public BambooSubsystemImpl() {        routerInitialized = false;    }    /**     * Method leaf_set_changed     *     * @param preds     * @param succs     * @param user_data     */    public void leaf_set_changed(BambooNeighborInfo[] preds,                                 BambooNeighborInfo[] succs, Object user_data) {        receipent.handleLeafsetChange();    }    /**     * Method routing_table_changed     *     * @param added     * @param removed     * @param user_data     */    public void routing_table_changed(BambooNeighborInfo[] added,                                      BambooNeighborInfo[] removed,                                      Object user_data) {}    /**     * Method route_upcall     *     * @param src     * @param dest     * @param intermediate_src     * @param app_id     * @param iter     * @param payload     * @param user_data     */    public void route_upcall(BigInteger src, BigInteger dest,                             NodeId intermediate_src, long app_id,                             boolean iter, QuickSerializable payload,                             Object user_data) {        if (Output.debuggingEnabled) {            logger.debug(new LogMessage(new Object[]{                "Proccessing route upcall from ",                src, " to ", dest}));        }        Payload message = ((NetworkMessageEmulator) payload).getItem();        boolean stopSending = receipent.handleMessageUpCall(message,                                  (src.equals(myID)));        if ( !stopSending) {            router.route_continue(src, dest, intermediate_src, app_id, true,                                  iter, payload);        }    }    /**     * Method route_deliver     *     * @param src     * @param dest     * @param immediate_src     * @param app_id     * @param payload     * @param user_data     */    public void route_deliver(BigInteger src, BigInteger dest,                              NodeId immediate_src, long app_id,                              QuickSerializable payload, Object user_data) {        if (Output.debuggingEnabled) {            logger.debug(new LogMessage(new Object[]{                "Proccessing route delivery from ",                src, " to ", dest}));        }        Payload message = ((NetworkMessageEmulator) payload).getItem();        receipent.handleMessageDelivery(message, src.equals(myID));    }    /**     * Method application_registered     *     * @param app_id     * @param success     * @param msg     * @param modulus     * @param guid_digits     * @param digit_values     * @param node_guid     * @param user_data     */    public void application_registered(long app_id, boolean success,                                       String msg, BigInteger modulus,                                       int guid_digits, int digit_values,                                       BigInteger node_guid, Object user_data) {        this.modulus = modulus;        myID = node_guid;        myBitID = new BitID(myID);        routerInitialized = true;    }    /**     * Method bind     *     * @param receipent     * @param localPort     * @param localAddress     * @param applicationID     */    public void bind(Bamboo receipent, int localPort, InetAddress localAddress,                     long applicationID) {        this.receipent = receipent;        NodeId thisNode = new NodeId(localPort, localAddress);        router = RouterCallbackInterface.instance(thisNode);        if (Output.debuggingEnabled) {            logger.debug(new LogMessage(new Object[]{                "Trying to register application ",                String.valueOf(applicationID),                " for node ", thisNode}));        }        router.register_app(applicationID, this, this, this, this, this, this,                            this, this, this, this);    }    /**     * Method getLocationID     *     * @return     */    public BitID getLocationID() {        return myBitID;    }    /**     * Method sendMessage     *     * @param destination     * @param appID     * @param upcalls     * @param iterative     * @param payload     */    public void sendMessage(BitID destination, long appID, boolean upcalls,                            boolean iterative, Payload payload) {        if ((router != null) && (routerInitialized)) {            QuickSerializable message = new NetworkMessageEmulator(payload);            router.route_init(destination.bigIntegerValue(), appID, upcalls,                              iterative, message);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -