All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.emc.mongoose.base.item.op.path.PathOperationImpl Maven / Gradle / Ivy

There is a newer version: 4.3.10
Show newest version
package com.emc.mongoose.base.item.op.path;

import static java.lang.System.nanoTime;

import com.emc.mongoose.base.item.PathItem;
import com.emc.mongoose.base.item.op.OpType;
import com.emc.mongoose.base.item.op.OperationImpl;
import com.emc.mongoose.base.storage.Credential;

/** Created by kurila on 30.01.17. */
public class PathOperationImpl extends OperationImpl
				implements PathOperation {

	protected volatile long countBytesDone;
	protected volatile long respDataTimeStart;

	public PathOperationImpl() {
		super();
	}

	public PathOperationImpl(
					final int originIndex, final OpType opType, final I item, final Credential credential) {
		super(originIndex, opType, item, null, null, credential);
		item.reset();
	}

	protected PathOperationImpl(final PathOperationImpl other) {
		super(other);
		this.countBytesDone = other.countBytesDone;
		this.respDataTimeStart = other.respDataTimeStart;
	}

	@Override
	public PathOperationImpl result() {
		buildItemPath(item, dstPath == null ? srcPath : dstPath);
		return new PathOperationImpl<>(this);
	}

	@Override
	public long countBytesDone() {
		return countBytesDone;
	}

	@Override
	public void countBytesDone(final long n) {
		this.countBytesDone = n;
	}

	@Override
	public long respDataTimeStart() {
		return respDataTimeStart;
	}

	@Override
	public void startDataResponse() {
		respDataTimeStart = START_OFFSET_MICROS + nanoTime() / 1000;
	}
}