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

com.bagri.server.hazelcast.task.index.IndexRemover Maven / Gradle / Ivy

The newest version!
package com.bagri.server.hazelcast.task.index;

import static com.bagri.server.hazelcast.serialize.TaskSerializationFactory.cli_factory_id;
import static com.bagri.server.hazelcast.serialize.TaskSerializationFactory.cli_RemoveIndexTask;

import java.io.IOException;
import java.util.concurrent.Callable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.bagri.core.system.Index;
import com.bagri.server.hazelcast.impl.SchemaRepositoryImpl;
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.nio.serialization.IdentifiedDataSerializable;
import com.hazelcast.spring.context.SpringAware;

@SpringAware
public class IndexRemover implements Callable, IdentifiedDataSerializable { 
	
	private static final transient Logger logger = LoggerFactory.getLogger(IndexRemover.class);
	
	private String index;
	private transient SchemaRepositoryImpl xdmRepo;
    
	public IndexRemover() {
		//
	}
	
	public IndexRemover(String index) {
		this.index = index;
	}

    @Autowired
	public void setXDMRepository(SchemaRepositoryImpl xdmRepo) {
		this.xdmRepo = xdmRepo;
	}
	
	@Override
	public Boolean call() throws Exception {
		logger.trace("call.enter");
		long stamp = System.currentTimeMillis();
		boolean result = xdmRepo.dropSchemaIndex(index);
		stamp = System.currentTimeMillis() - stamp;
		logger.trace("call.exit; returning: {}; time taken: {}", result, stamp);
		return result;
	}
    
	@Override
	public int getId() {
		return cli_RemoveIndexTask;
	}

	@Override
	public int getFactoryId() {
		return cli_factory_id;
	}

	@Override
	public void readData(ObjectDataInput in) throws IOException {
		index = in.readUTF();
	}
	
	@Override
	public void writeData(ObjectDataOutput out) throws IOException {
		out.writeUTF(index);
	}


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy