Exemplo n.º 1
0
 public void testBackupForIsCorrect() {
   cacheManager.getCache(); // start default cache
   cacheManager.defineConfiguration("nycBackup", nycBackup.build());
   cacheManager.getCache("nycBackup");
   SitesConfiguration sitesConfig = cache("nycBackup").getCacheConfiguration().sites();
   assertEquals(CacheContainer.DEFAULT_CACHE_NAME, sitesConfig.backupFor().remoteCache());
   assertEquals("NYC", sitesConfig.backupFor().remoteSite());
   sitesConfig.backupFor().isBackupFor("NYC", CacheContainer.DEFAULT_CACHE_NAME);
 }
Exemplo n.º 2
0
 private void writeBackup(XMLExtendedStreamWriter writer, Configuration configuration)
     throws XMLStreamException {
   SitesConfiguration sites = configuration.sites();
   if (sites.allBackups().size() > 0) {
     writer.writeStartElement(Element.BACKUPS);
     for (BackupConfiguration backup : sites.allBackups()) {
       writer.writeStartElement(Element.BACKUP);
       backup.attributes().write(writer);
       AttributeSet stateTransfer = backup.stateTransfer().attributes();
       if (stateTransfer.isModified()) {
         writer.writeStartElement(Element.STATE_TRANSFER);
         stateTransfer.write(
             writer, XSiteStateTransferConfiguration.CHUNK_SIZE, Attribute.CHUNK_SIZE);
         stateTransfer.write(
             writer, XSiteStateTransferConfiguration.MAX_RETRIES, Attribute.MAX_RETRIES);
         stateTransfer.write(writer, XSiteStateTransferConfiguration.TIMEOUT, Attribute.TIMEOUT);
         stateTransfer.write(
             writer, XSiteStateTransferConfiguration.WAIT_TIME, Attribute.WAIT_TIME);
         writer.writeEndElement();
       }
       AttributeSet takeOffline = backup.takeOffline().attributes();
       if (takeOffline.isModified()) {
         writer.writeStartElement(Element.TAKE_OFFLINE);
         takeOffline.write(
             writer,
             TakeOfflineConfiguration.AFTER_FAILURES,
             Attribute.TAKE_BACKUP_OFFLINE_AFTER_FAILURES);
         takeOffline.write(
             writer,
             TakeOfflineConfiguration.MIN_TIME_TO_WAIT,
             Attribute.TAKE_BACKUP_OFFLINE_MIN_WAIT);
         writer.writeEndElement();
       }
       writer.writeEndElement();
     }
     writer.writeEndElement();
   }
 }