2017-03-08 5 views
0

라즈베리 PI에서 KAA 클라이언트 SDK (JAVA)를 시작하면 CPU 사용률이 최대 100 %까지 증가합니다. 마자는 CPU 사용량이 정상PI에서 KA 클라이언트 시작시 높은 CPU 사용량

로 다시 떨어 프로세스를 종료로 아래 내가 라즈베리 파이에

public class NotificationSystemTestApp { 

    private static final Logger LOG = LoggerFactory.getLogger(NotificationSystemTestApp.class); 

    public static void main(String[] args) throws InterruptedException { 
     /*System.out.println(encryptString("abcd", "12332sd1133sdssd45")); 
     return;*/ 
     new NotificationSystemTestApp().launch(); 
    } 

    private void launch() throws InterruptedException { 
     // Create client for Kaa SDK 

     final KaaClient kaaClient; 
     DesktopKaaPlatformContext desktopKaaPlatformContext = new DesktopKaaPlatformContext(); 
     final CountDownLatch startupLatch = new CountDownLatch(1); 
     kaaClient = Kaa.newClient(desktopKaaPlatformContext, new SimpleKaaClientStateListener() { 
      @Override 
      public void onStarted() { 
       LOG.info("--= Kaa client started =--"); 
       startupLatch.countDown(); 
      } 

      @Override 
      public void onStopped() { 
       LOG.info("--= Kaa client stopped =--"); 
      } 
     }, true); 

     kaaClient.setProfileContainer(new ProfileContainer() { 
      public ClientProfile getProfile() { 
       return new ClientProfile() {{ 
        setClientProfileInfo(new ProfileInfo() {{ 
         setRidlrId("R_00001"); 
         setStationName("Mumbai"); 
         setEquipmentId("EQ0006"); 
         setStationId("5"); 
        }}); 
       }}; 
      } 
     }); 
     // Registering listener for topic updates 

     kaaClient.start(); 
     startupLatch.await(); 

     kaaClient.addTopicListListener(new NotificationTopicListListener() { 
      public void onListUpdated(List<Topic> topicList) { 
       System.out.println("Topic list updated!"); 
       for (Topic topic : topicList) { 
        LOG.info("Received topic with id {} and name {}", topic.getId(), topic.getName()); 
       } 
      } 
     }); 

     final ScanInfo scanInfo = new ScanInfo() {{ 
      setDestinationId("12"); 
      setSourceId("3"); 
      setEquipmentId("R_00001"); 
      setScanTime(System.currentTimeMillis()/1000); 
      setEvent("ENTRY"); 
      setTransactionId(UUID.randomUUID().toString()); 
     }}; 

     kaaClient.attachEndpoint(new EndpointAccessToken("1234"), new OnAttachEndpointOperationCallback() { 
      @Override 
      public void onAttach(SyncResponseResultType result, EndpointKeyHash resultContext) { 

      } 
     }); 
     kaaClient.attachUser("user1", "1234", new UserAttachCallback() { 
      public void onAttachResult(UserAttachResponse response) { 
       System.out.println("Attach User Success - " + response.getResult()); 
      } 
     }); 


     try { 
      Thread.sleep(2000); 
     } catch (InterruptedException e) { 
      LOG.error("FATA", e); 
     } 


     LOG.debug("End Point key hash - " + kaaClient.getEndpointKeyHash()); 
     while (true) { 
      kaaClient.addLogRecord(new LoggerSchema() {{ 
       setData(""); 
       setMessageType(""); 
      }}); 
      Thread.sleep(10); 
     } 
    } 
} 

감사합니다, Rizwan을 KAA 클라이언트를 시작하고있는 KAA를 시작하는 데 사용하는 코드입니다

답변

0

앞서 보았 듯이 Kaa 서버에 업로드하기 위해 로그 레코드를 계속 추가합니다. 지연 시간은 응용 프로그램을 실행중인 Raspberry PI 시스템에 비해 너무 짧은 10 밀리 초입니다.

구성에 따라 Kaa 클라이언트는 각 로그 레코드에 대해 상당한 처리 오버 헤드를 추가하여 다른 Java 스레드에서 처리하여 CPU가 지속적으로 새 레코드 추가 및 처리를 유발할 수 있습니다.

'while (true)'루프의 지연을 늘리고 다른 로그 업로드 설정으로 CPU 사용량을 확인하십시오.

이 정보로 문제를 해결하기에 충분하지 않은 경우 조사를 위해 Kaa 클라이언트 및 Kaa 서버의 로그를 추가하십시오.