parent
278c3d3aae
commit
f3b3b6dbf8
@ -0,0 +1,68 @@
|
||||
package com.platform.controller;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.base.BaseController;
|
||||
import com.platform.entities.VolumeInitEntity;
|
||||
import com.platform.service.IVolumeService;
|
||||
import com.platform.utils.Configs;
|
||||
|
||||
@Controller
|
||||
public class VolumeController extends BaseController{
|
||||
|
||||
public static Logger log = Configs.DAILY_ROLLING_LOGGER;
|
||||
|
||||
@Resource(name = "volumeService")
|
||||
private IVolumeService volumeService;
|
||||
|
||||
|
||||
@RequestMapping(value = "/volume/insert", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public void volumeInsert(HttpServletRequest res, HttpServletResponse req,
|
||||
@RequestBody VolumeInitEntity entity) throws Exception {
|
||||
Configs.CONSOLE_LOGGER.error("/oracle/{name}/extract");
|
||||
volumeService.save(entity);
|
||||
req.setStatus(200);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/volume/{name}/delete", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public void volumeDelete(HttpServletRequest res, HttpServletResponse req,
|
||||
@RequestBody VolumeInitEntity entity) throws Exception {
|
||||
Configs.CONSOLE_LOGGER.error("/oracle/{name}/extract");
|
||||
volumeService.delete(entity);
|
||||
req.setStatus(200);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/volume/{name}/start", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public void volumeStart(HttpServletRequest res, HttpServletResponse req,
|
||||
@RequestBody VolumeInitEntity entity) throws Exception {
|
||||
Configs.CONSOLE_LOGGER.error("/oracle/{name}/extract");
|
||||
res.setCharacterEncoding("UTF-8");
|
||||
volumeService.start(entity);
|
||||
req.setStatus(200);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/volume/{name}/stop", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public void volumeStop(HttpServletRequest res, HttpServletResponse req,
|
||||
@RequestBody VolumeInitEntity entity) throws Exception {
|
||||
Configs.CONSOLE_LOGGER.error("/oracle/{name}/extract");
|
||||
res.setCharacterEncoding("UTF-8");
|
||||
volumeService.stop(entity);
|
||||
req.setStatus(200);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.platform.service;
|
||||
|
||||
import com.platform.entities.VolumeInitEntity;
|
||||
|
||||
public interface IVolumeService {
|
||||
|
||||
public int save(VolumeInitEntity entity) throws Exception;
|
||||
|
||||
public int delete(VolumeInitEntity entity) throws Exception;
|
||||
|
||||
public int start(VolumeInitEntity entity) throws Exception;
|
||||
|
||||
public int stop(VolumeInitEntity entity) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.platform.service.impl;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.platform.dao.VolumeDao;
|
||||
import com.platform.entities.VolumeInitEntity;
|
||||
import com.platform.glusterfs.SetVolume;
|
||||
import com.platform.service.IVolumeService;
|
||||
|
||||
@Service(value = "volumeService")
|
||||
public class VolumeServiceImpl implements IVolumeService {
|
||||
|
||||
/** gfs的api */
|
||||
SetVolume volumeService = new SetVolume();
|
||||
|
||||
@Resource(name = "volumeDao")
|
||||
private VolumeDao volumeDao;
|
||||
|
||||
|
||||
@Override
|
||||
public int save(VolumeInitEntity entity) throws Exception {
|
||||
//createVolume("lili_test1", 0, "distributed", bricksToCreate, "/home/lili_test1_point")
|
||||
if (null == entity.getBricks()) {
|
||||
return -1;
|
||||
}
|
||||
volumeService.createVolume(entity.getName(), 0, "distributed", entity.getBricks(), entity.getMountPoint());
|
||||
volumeDao.save(entity);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(VolumeInitEntity entity) throws Exception {
|
||||
if (null == entity.getName() || "".equals(entity.getName())) {
|
||||
return -1;
|
||||
}
|
||||
volumeService.deleteVolume(entity.getName());
|
||||
volumeDao.remove(entity.getName());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int start(VolumeInitEntity entity) throws Exception {
|
||||
if (null == entity.getName() || "".equals(entity.getName())) {
|
||||
return -1;
|
||||
}
|
||||
return volumeService.startVolume(entity.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int stop(VolumeInitEntity entity) throws Exception {
|
||||
if (null == entity.getName() || "".equals(entity.getName())) {
|
||||
return -1;
|
||||
}
|
||||
return volumeService.stopVolume(entity.getName());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue