|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson2.JSON; | 
|---|
|  |  |  | import com.alibaba.fastjson2.JSONObject; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.VManageBootstrap; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.common.SystemAllInfo; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.common.VersionPo; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.conf.SipConfig; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.genersoft.iot.vmp.service.*; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.service.bean.MediaServerLoad; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.utils.SpringBeanFactory; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.vmanager.bean.ResourceInfo; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.vmanager.bean.SystemConfigInfo; | 
|---|
|  |  |  | import gov.nist.javax.sip.SipStackImpl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import io.swagger.v3.oas.annotations.Operation; | 
|---|
|  |  |  | import io.swagger.v3.oas.annotations.Parameter; | 
|---|
|  |  |  | import io.swagger.v3.oas.annotations.tags.Tag; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | 
|---|
|  |  |  | import org.springframework.util.ObjectUtils; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.sip.ListeningPoint; | 
|---|
|  |  |  | import javax.sip.ObjectInUseException; | 
|---|
|  |  |  | import javax.sip.SipProvider; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @SuppressWarnings("rawtypes") | 
|---|
|  |  |  | @Tag(name = "服务控制") | 
|---|
|  |  |  | @CrossOrigin | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/api/server") | 
|---|
|  |  |  | public class ServerController { | 
|---|
|  |  |  | 
|---|
|  |  |  | @Value("${server.port}") | 
|---|
|  |  |  | private int serverPort; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ThreadPoolTaskExecutor taskExecutor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private IRedisCatchStorage redisCatchStorage; | 
|---|
|  |  |  | 
|---|
|  |  |  | @GetMapping(value = "/restart") | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | public void restart() { | 
|---|
|  |  |  | taskExecutor.execute(()-> { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Thread.sleep(3000); | 
|---|
|  |  |  | SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); | 
|---|
|  |  |  | SipStackImpl stack = (SipStackImpl) up.getSipStack(); | 
|---|
|  |  |  | stack.stop(); | 
|---|
|  |  |  | Iterator listener = stack.getListeningPoints(); | 
|---|
|  |  |  | while (listener.hasNext()) { | 
|---|
|  |  |  | stack.deleteListeningPoint((ListeningPoint) listener.next()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Iterator providers = stack.getSipProviders(); | 
|---|
|  |  |  | while (providers.hasNext()) { | 
|---|
|  |  |  | stack.deleteSipProvider((SipProvider) providers.next()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | VManageBootstrap.restart(); | 
|---|
|  |  |  | } catch (InterruptedException | ObjectInUseException e) { | 
|---|
|  |  |  | throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | //        taskExecutor.execute(()-> { | 
|---|
|  |  |  | //            try { | 
|---|
|  |  |  | //                Thread.sleep(3000); | 
|---|
|  |  |  | //                SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); | 
|---|
|  |  |  | //                SipStackImpl stack = (SipStackImpl) up.getSipStack(); | 
|---|
|  |  |  | //                stack.stop(); | 
|---|
|  |  |  | //                Iterator listener = stack.getListeningPoints(); | 
|---|
|  |  |  | //                while (listener.hasNext()) { | 
|---|
|  |  |  | //                    stack.deleteListeningPoint((ListeningPoint) listener.next()); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                Iterator providers = stack.getSipProviders(); | 
|---|
|  |  |  | //                while (providers.hasNext()) { | 
|---|
|  |  |  | //                    stack.deleteSipProvider((SipProvider) providers.next()); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                VManageBootstrap.restart(); | 
|---|
|  |  |  | //            } catch (InterruptedException | ObjectInUseException e) { | 
|---|
|  |  |  | //                throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage()); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        }); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Operation(summary = "获取系统信息信息") | 
|---|