Project

General

Profile

« Previous | Next » 

Revision 1039

Added by Jing Tao over 22 years ago

Add a hub control in write and writeData method. If hub==super, metacat can replicate any document in its database to any server in server list. If it is not super, metacat only replicate local documents to any server in server list. If a document' home host is not itself, metacat only force replicate the document to the document's home host.

View differences:

src/edu/ucsb/nceas/metacat/DocumentImpl.java
387 387
      MetaCatUtil util = new MetaCatUtil();
388 388
      if ((util.getOption("replicationdata")).equals("on"))
389 389
      {
390
        ForceReplicationHandler frh = new 
391
                               ForceReplicationHandler(accnum, "insert", false);
392
      }
390
        Connection dbConn = util.getConnection();
391
        //this is local server, force replication to every server in its server
392
        //list
393
        if (serverCode==1)
394
        {
395
          
396
          ForceReplicationHandler frh = new ForceReplicationHandler(accnum,
397
                  "insert",false,ReplicationHandler.buildServerList(dbConn));
398
          util.returnConnection(dbConn);
399
        }//if
400
        else
401
        {
402
          //if it is super hub, replication to server list
403
          if ((util.getOption("hub")).equals("super"))
404
          {
405
            ForceReplicationHandler frh = new ForceReplicationHandler(accnum, 
406
                true, ReplicationHandler.buildServerList(dbConn));
407
            util.returnConnection(dbConn);
408
          }
409
          else
410
          {
411
            //only replicate to home host of the document
412
            String docId=util.getDocIdFromString(accnum);
413
            ForceReplicationHandler frh = new ForceReplicationHandler(accnum, 
414
                true, ReplicationHandler.getHomeServer(docId));
415
          }
416
        }
417
      }//if
393 418
    }//if
394 419
 }
395 420
  
......
1286 1311
          throw e;
1287 1312
        }
1288 1313
                
1289
        //after inserting the document locally, tell the document's home server
1290
        //to come get a copy from here.
1291
        //ture mean it is xml document
1292
        ForceReplicationHandler frh = new ForceReplicationHandler(accnum, true);
1293 1314
        
1315
        
1316
        //If Metacat is super hub, tell all servers in its server list to get 
1317
        //the new document, ture mean it is xml document
1318
        if ((util.getOption("hub")).equals("super"))
1319
        {
1320
          ForceReplicationHandler frh = new ForceReplicationHandler(accnum, 
1321
                true, ReplicationHandler.buildServerList(conn));
1322
        }
1323
        else
1324
        {
1325
          //after inserting the document locally, tell the document's homeserver
1326
          //to come get a copy from here.
1327
         
1328
          ForceReplicationHandler frh = new ForceReplicationHandler(accnum, 
1329
                true, ReplicationHandler.getHomeServer(docid));
1330
        }
1294 1331
        return (accnum);
1295 1332
      }
1296 1333

  
......
1351 1388
      //start the thread to replicate this new document out to the other servers
1352 1389
      //true mean it is xml document
1353 1390
      ForceReplicationHandler frh = new ForceReplicationHandler
1354
                                                         (accnum, action, true);
1391
                (accnum, action, true,ReplicationHandler.buildServerList(conn));
1355 1392
      
1356 1393
    }
1357 1394
      

Also available in: Unified diff