def on_deleted(self, event):

        # Deletes happen quickly when compaction completes.
        # Rather than do a backup for each file we only backup when
        # a -Data.db component is deleted.

        file_path = event.src_path
        if cassandra.is_snapshot_path(file_path):
            self.log.info("Ignoring deleted snapshot path %s", file_path)
            return

        try:
            component = cassandra.SSTableComponent(file_path, is_deleted=True)
        except (ValueError):
            self.log.info("Ignoring deleted non Cassandra file %s", file_path)
            return

        if component.component != cassandra.Components.DATA:
            self.log.info("Ignoring deleted non %s component %s",
                          cassandra.Components.DATA, file_path)
            return

        # We want to do a backup so we know this sstable was removed.
        ks_manifest = self._get_ks_manifest(component.keyspace)
        ks_manifest.remove_sstable(component)
        self.log.info("Queuing backup after deletion of %s", file_path)
        self.file_queue.put(
            BackupMessage(None, ks_manifest.snapshot(), component))
        return
Example #2
0
    def on_deleted(self, event):
        
        # Deletes happen quickly when compaction completes. 
        # Rather than do a backup for each file we only backup when 
        # a -Data.db component is deleted. 
        
        file_path = event.src_path
        if cassandra.is_snapshot_path(file_path):
            self.log.info("Ignoring deleted snapshot path %s", file_path)
            return
        
        try:
            component = cassandra.SSTableComponent(file_path, is_deleted=True)
        except (ValueError):
            self.log.info("Ignoring deleted non Cassandra file %s", file_path)
            return
    
        if component.component != cassandra.Components.DATA:
            self.log.info("Ignoring deleted non %s component %s", 
                cassandra.Components.DATA, file_path)
            return

        # We want to do a backup so we know this sstable was removed. 
        ks_manifest = self._get_ks_manifest(component.keyspace)
        ks_manifest.remove_sstable(component)
        self.log.info("Queuing backup after deletion of %s", file_path)
        self.file_queue.put(
            BackupMessage(None, ks_manifest.snapshot(), component))
        return
Example #3
0
    def _maybe_queue_file(self, file_path, enqueue=True):

        with file_util.FileReferenceContext(file_path) as file_ref:
            if file_ref is None:
                # File was deleted before we could link it.
                self.log.info("Ignoring deleted path %s", file_path)
                return False

            #if cassandra.is_snapshot_path(file_ref.stable_path):
            #    self.log.info("Ignoring snapshot path %s", file_ref.stable_path)
            #    return False
            if not cassandra.is_snapshot_path(file_ref.stable_path):
                #self.log.info("Ignoring non snapshot path %s", file_ref.stable_path)
                return False

            try:
                component = cassandra.SSTableComponent(file_ref.stable_path)
            except (ValueError):
                self.log.info("Ignoring non Cassandra file %s",
                              file_ref.stable_path)
                return False

            if component.temporary:
                self.log.info("Ignoring temporary file %s",
                              file_ref.stable_path)
                return False

            if component.keyspace in self.exclude_keyspaces:
                self.log.info("Ignoring file %s from excluded "\
                    "keyspace %s", file_ref.stable_path, component.keyspace)
                return False

            if (component.keyspace.lower()
                    == "system") and (not self.include_system_keyspace):

                self.log.info("Ignoring system keyspace file %s",
                              file_ref.stable_path)
                return False

            # Update the manifest with this component
            ks_manifest = self._get_ks_manifest(component.keyspace)
            ks_manifest.add_component(component)
            if enqueue:
                self.log.info("Queueing file %s", file_ref.stable_path)
                self.file_queue.put(
                    BackupMessage(file_ref, ks_manifest.snapshot(), component))
                # Do not delete the file ref when we exit the context
                file_ref.ignore_next_exit = True

        return True
Example #4
0
    def _maybe_queue_file(self, file_path, enqueue=True):
        
        with file_util.FileReferenceContext(file_path) as file_ref:
            if file_ref is None:
                # File was deleted before we could link it.
                self.log.info("Ignoring deleted path %s", file_path)
                return False
                
            if cassandra.is_snapshot_path(file_ref.stable_path):
                self.log.info("Ignoring snapshot path %s", file_ref.stable_path)
                return False

            try:
                component = cassandra.SSTableComponent(file_ref.stable_path)
            except (ValueError):
                self.log.info("Ignoring non Cassandra file %s", 
                    file_ref.stable_path)
                return False
                
            if component.temporary:
                self.log.info("Ignoring temporary file %s", file_ref.stable_path)
                return False

            if component.keyspace in self.exclude_keyspaces:
                self.log.info("Ignoring file %s from excluded "\
                    "keyspace %s", file_ref.stable_path, component.keyspace)
                return False

            if (component.keyspace.lower() == "system") and (
                not self.include_system_keyspace):

                self.log.info("Ignoring system keyspace file %s", 
                    file_ref.stable_path)
                return False
            
            # Update the manifest with this component
            ks_manifest = self._get_ks_manifest(component.keyspace)
            ks_manifest.add_component(component)
            if enqueue:
                self.log.info("Queueing file %s", file_ref.stable_path)
                self.file_queue.put(
                    BackupMessage(file_ref, ks_manifest.snapshot(),component))
                # Do not delete the file ref when we exit the context
                file_ref.ignore_next_exit = True

        return True