/*
 * Copyright (C) 2015 hops.io.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.hops.metadata.hdfs.entity;

import io.hops.metadata.common.FinderType;

public class MetadataLogEntry {
  private final int datasetId;
  private final int inodeId;
  private final int inodePartitionId;
  private final int inodeParentId;
  private final String inodeName;
  private long timestamp;
  private final Operation operation;

  public enum Operation {
    ADD,
    DELETE
  }

  public MetadataLogEntry(int datasetId, int inodeId, int inodePartitionId,
      int inodeParentId, String inodeName, Operation
      operation) {
    this(datasetId, inodeId, inodePartitionId, inodeParentId, inodeName, 0,
        operation);
    updateTimestamp();
  }

  public MetadataLogEntry(int datasetId, int inodeId, int inodePartitionId,
      int inodeParentId, String inodeName, long timestamp, Operation
      operation) {
    this.datasetId = datasetId;
    this.inodeId = inodeId;
    this.inodePartitionId = inodePartitionId;
    this.inodeParentId = inodeParentId;
    this.inodeName = inodeName;
    this.timestamp = timestamp;
    this.operation = operation;
  }

  public int getDatasetId() {
    return datasetId;
  }

  public int getInodeId() {
    return inodeId;
  }

  public long getTimestamp() {
    return timestamp;
  }

  public long updateTimestamp() {
    this.timestamp = System.currentTimeMillis();
    return timestamp;
  }

  public Operation getOperation() {
    return operation;
  }

  public short getOperationOrdinal() {
    return (short) operation.ordinal();
  }

  public int getInodePartitionId() {
    return inodePartitionId;
  }

  public int getInodeParentId() {
    return inodeParentId;
  }

  public String getInodeName() {
    return inodeName;
  }
}

@@ -633,52 +633,8 @@
 y;%0A%0A
-import io.hops.metadata.common.FinderType;%0A%0A
 publ
@@ -1191,31 +1191,30 @@
 n);%0A    
-updateT
+this.t
 imestamp
 ();%0A  %7D%0A
@@ -1205,16 +1205,43 @@
 imestamp
+ = System.currentTimeMillis
 ();%0A  %7D%0A
@@ -1858,57 +1858,8 @@
 ) %7B%0A
-    this.timestamp = System.currentTimeMillis();%0A
     
@@ -1857,32 +1857,34 @@
 () %7B%0A    return 
+++
 timestamp;%0A  %7D%0A%0A
@@ -2195,24 +2195,24 @@
 odeName() %7B%0A
-
     return i
@@ -2224,11 +2224,386 @@
 ame;%0A  %7D
+%0A%0A  @Override%0A  public String toString() %7B%0A    return %22MetadataLogEntry%7B%22 +%0A        %22datasetId=%22 + datasetId +%0A        %22, inodeId=%22 + inodeId +%0A        %22, inodePartitionId=%22 + inodePartitionId +%0A        %22, inodeParentId=%22 + inodeParentId +%0A        %22, inodeName='%22 + inodeName + '%5C'' +%0A        %22, timestamp=%22 + timestamp +%0A        %22, operation=%22 + operation +%0A        '%7D';%0A  %7D
 %0A%7D%0A

increment timestamp