def deleteDataAndMetaFromIndividualChunk(self, meta, username, filename):

        node, seqNo, replicaNode = str(meta[0]), meta[1], str(meta[2])
        metaDataKey = username + "_" + filename
        dataChunkKey = username + "_" + filename + "_" + str(seqNo)

        if (db.keyExists(metaDataKey) == 1):
            print(
                "deleteDataAndMetaFromIndividualChunk: Deleting the metadataEntry from local db :",
                node)
            db.deleteEntry(metaDataKey)

        if (db.keyExists(dataChunkKey)):
            print(
                "deleteDataAndMetaFromIndividualChunk: Deleting the data chunk from local db:",
                node)
            db.deleteEntry(dataChunkKey)

        active_ip_channel_dict = self.activeNodesChecker.getActiveChannels()

        if (node != self.serverAddress and node in active_ip_channel_dict):
            channel = active_ip_channel_dict[node]
            stub = fileService_pb2_grpc.FileserviceStub(channel)
            response = stub.FileDelete(
                fileService_pb2.FileInfo(username=username,
                                         filename=filename,
                                         seqNo=seqNo))

            if (response.success == True):
                print(
                    "deleteDataAndMetaFromIndividualChunk : Successfully deleted chunk from node : ",
                    node)
            else:
                print(
                    "deleteDataAndMetaFromIndividualChunk : Chunk could not be deleted from node :",
                    node)

        if (replicaNode != self.serverAddress and replicaNode
                in self.activeNodesChecker.getActiveChannels()):
            print("Deleting ")
            channel = active_ip_channel_dict[replicaNode]
            stub = fileService_pb2_grpc.FileserviceStub(channel)
            response = stub.FileDelete(
                fileService_pb2.FileInfo(username=username,
                                         filename=filename,
                                         seqNo=seqNo))

            print(type(response.success))
            if (response.success == True):
                print("Successfully deleted chunk from ReplicaNode : ", node)
            else:
                print("Chunk could not be deleted from ReplicaNode :", node)
    def FileDelete(self, request, context):
        print("In FileDelete")

        if (self.fileExists(request.username, request.filename) == False):
            return fileService_pb2.ack(
                success=False,
                message="File {} does not exist.".format(request.filename))

        fileMeta = db.parseMetaData(request.username, request.filename)
        print("FileMeta = ", fileMeta)

        primaryIP, replicaIP = -1, -1
        channel1, channel2 = -1, -1
        if (fileMeta[0] in self.clusterLeaders):
            primaryIP = self.clusterLeaders[fileMeta[0]]
            channel1 = self.clusterStatus.isChannelAlive(primaryIP)

        if (fileMeta[1] in self.clusterLeaders):
            replicaIP = self.clusterLeaders[fileMeta[1]]
            channel2 = self.clusterStatus.isChannelAlive(replicaIP)

        print("PrimarIP={}, replicaIP={}".format(primaryIP, replicaIP))

        if (channel1 != -1):
            print("Making fileDelete call to primary")
            stub = fileService_pb2_grpc.FileserviceStub(channel1)
            response = stub.FileDelete(
                fileService_pb2.FileInfo(username=request.username,
                                         filename=request.filename))
            print("Received response = ", response.success)

        if (channel2 != -1):
            print("Making fileDelete call to replica")
            stub = fileService_pb2_grpc.FileserviceStub(channel2)
            response = stub.FileDelete(
                fileService_pb2.FileInfo(username=request.username,
                                         filename=request.filename))
            print("Received response = ", response.success)

        if (response.success == True):
            db.deleteEntry(request.username + "_" + request.filename)
            print("Successfully deleted.")
            return fileService_pb2.ack(
                success=True,
                message="File successfully deleted from cluster : " +
                fileMeta[0])
        else:
            print("Could not delete from replica")
            return fileService_pb2.ack(success=False, message="Internal error")
Example #3
0
    def FileDelete(self, request, data):
        username = request.username
        filename = request.filename

        if (int(db.get("primaryStatus")) == 1):

            if (self.fileExists(username, filename) == 0):
                print("File does not exist")
                return fileService_pb2.ack(success=False,
                                           message="File does not exist")

            print("Fetching metadata from leader")
            metadata = db.parseMetaData(request.username, request.filename)
            print("Successfully retrieved metadata from leader")

            deleteHelper = DeleteHelper(self.hostname, self.serverPort,
                                        self.activeNodesChecker)
            deleteHelper.deleteFileChunksAndMetaFromNodes(
                username, filename, metadata)

            return fileService_pb2.ack(
                success=True,
                message="Successfully deleted file from the cluster")

        else:
            seqNo = -1

            try:
                seqNo = request.seqNo
            except:
                return fileService_pb2.ack(success=False,
                                           message="Internal Error")

            metaDataKey = username + "_" + filename
            dataChunkKey = username + "_" + filename + "_" + str(seqNo)

            if (db.keyExists(metaDataKey) == 1):
                print("FileDelete: Deleting the metadataEntry from local db :")
                db.deleteEntry(metaDataKey)
            if (db.keyExists(dataChunkKey)):
                print("FileDelete: Deleting the data chunk from local db: ")
                db.deleteEntry(dataChunkKey)

            return fileService_pb2.ack(
                success=True,
                message="Successfully deleted file from the cluster")
Example #4
0
 def deleteEntry_popup(self):
     orderGroupBox = QGroupBox("Headstone To Delete")
     tablename = QComboBox()
     tablename.addItems(db.getTables())
     hid = QComboBox()
     hid.addItems(db.getIDs(tablename.currentText()))
     layout = QFormLayout()
     layout.addRow(QLabel("Table"), tablename)
     layout.addRow(QLabel("ID"), hid)
     orderGroupBox.setLayout(layout)
     orderButtonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                       | QDialogButtonBox.Cancel)
     mainOrderLayout = QVBoxLayout()
     central_widget = QWidget()
     central_widget.setLayout(mainOrderLayout)
     mainOrderLayout.addWidget(orderGroupBox)
     mainOrderLayout.addWidget(orderButtonBox)
     self.setCentralWidget(central_widget)
     self.show()
     orderButtonBox.accepted.connect(
         lambda: db.deleteEntry(tablename.currentText(), hid.currentText()))
     orderButtonBox.accepted.connect(self.close)
     orderButtonBox.rejected.connect(self.close)