PolicyGroupByActiveThreadsDistributedNoCache.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.pdd.core.controllo_traffico.policy.driver.hazelcast;

  21. import org.openspcoop2.core.controllo_traffico.beans.ActivePolicy;
  22. import org.openspcoop2.core.controllo_traffico.beans.DatiCollezionati;
  23. import org.openspcoop2.core.controllo_traffico.beans.IDUnivocoGroupByPolicy;
  24. import org.openspcoop2.core.controllo_traffico.beans.MisurazioniTransazione;
  25. import org.openspcoop2.core.controllo_traffico.driver.PolicyException;
  26. import org.openspcoop2.core.controllo_traffico.driver.PolicyGroupByActiveThreadsType;
  27. import org.openspcoop2.core.controllo_traffico.driver.PolicyNotFoundException;
  28. import org.openspcoop2.utils.Map;
  29. import org.slf4j.Logger;

  30. import com.hazelcast.core.HazelcastInstance;

  31. /**
  32.  *
  33.  * Gestore contatori policy che lavora solo sulla copia distribuita.
  34.  *
  35.  * @author Francesco Scarlato (scarlato@link.it)
  36.  * @author $Author$
  37.  * @version $Rev$, $Date$
  38.  */
  39. public class PolicyGroupByActiveThreadsDistributedNoCache extends AbstractPolicyGroupByActiveThreadsDistributed {
  40.        
  41.    
  42.     public PolicyGroupByActiveThreadsDistributedNoCache(ActivePolicy policy, String uniqueIdMap, HazelcastInstance hazelcast) throws PolicyException {
  43.         super(policy, uniqueIdMap, PolicyGroupByActiveThreadsType.HAZELCAST_MAP, hazelcast);        
  44.     }

  45.    
  46.     @Override
  47.     public DatiCollezionati registerStartRequest(Logger log, String idTransazione, IDUnivocoGroupByPolicy datiGroupBy, Map<Object> ctx)
  48.             throws PolicyException {
  49.        
  50.         datiGroupBy = augmentIDUnivoco(datiGroupBy);
  51.        
  52.         return this.distributedMap.executeOnKey(datiGroupBy, new StartRequestProcessor(this.activePolicy,ctx));
  53.     }
  54.    
  55.    
  56.     @Override
  57.     public DatiCollezionati updateDatiStartRequestApplicabile(Logger log, String idTransazione,
  58.             IDUnivocoGroupByPolicy datiGroupBy, Map<Object> ctx) throws PolicyException, PolicyNotFoundException {
  59.        
  60.         datiGroupBy = augmentIDUnivoco(datiGroupBy);

  61.         DatiCollezionati datiCollezionati = this.distributedMap.executeOnKey(datiGroupBy, new UpdateDatiRequestProcessor(this.activePolicy, ctx));
  62.         //if (datiCollezionati != null) {
  63.         //  throw new PolicyNotFoundException("Non sono presenti alcun threads registrati per la richiesta con dati identificativi ["+datiGroupBy.toString()+"]");
  64.         //}
  65.         return datiCollezionati;
  66.     }
  67.    
  68.    
  69.     @Override
  70.     public void registerStopRequest(Logger log, String idTransazione, IDUnivocoGroupByPolicy datiGroupBy, Map<Object> ctx,
  71.             MisurazioniTransazione dati, boolean isApplicabile, boolean isViolata)
  72.             throws PolicyException, PolicyNotFoundException {

  73.         datiGroupBy = augmentIDUnivoco(datiGroupBy);

  74.         // Lavoro sulla copia remota
  75.         this.distributedMap.executeOnKey(datiGroupBy, new EndRequestProcessor(this.activePolicy, ctx, dati, isApplicabile, isViolata));        
  76.     }


  77.    
  78.        
  79. }