Exemplo n.º 1
0
  private void _loadIndexFromCluster(IndexAccessor indexAccessor, long localLastGeneration) {

    List<Address> clusterNodeAddresses = ClusterExecutorUtil.getClusterNodeAddresses();

    int clusterNodeAddressesCount = clusterNodeAddresses.size();

    if (clusterNodeAddressesCount <= 1) {
      if (_log.isDebugEnabled()) {
        _log.debug(
            "Do not load indexes because there is either one portal "
                + "instance or no portal instances in the cluster");
      }

      return;
    }

    ClusterRequest clusterRequest =
        ClusterRequest.createMulticastRequest(
            new MethodHandler(_getLastGenerationMethodKey, indexAccessor.getCompanyId()), true);

    ClusterExecutorUtil.execute(
        clusterRequest,
        new LoadIndexClusterResponseCallback(
            indexAccessor, clusterNodeAddressesCount, localLastGeneration));
  }
Exemplo n.º 2
0
  @Override
  public void portalLocalInetSocketAddressConfigured(
      InetSocketAddress inetSocketAddress, boolean secure) {

    if (!isEnabled() || (_localClusterNode.getPortalProtocol() != null)) {
      return;
    }

    try {
      _localClusterNode.setPortalInetSocketAddress(inetSocketAddress);

      if (secure) {
        _localClusterNode.setPortalProtocol(Http.HTTPS);
      } else {
        _localClusterNode.setPortalProtocol(Http.HTTP);
      }

      memberJoined(_localAddress, _localClusterNode);

      ClusterRequest clusterRequest =
          ClusterRequest.createMulticastRequest(_localClusterNode, true);

      _controlJChannel.send(null, clusterRequest);
    } catch (Exception e) {
      _log.error("Unable to determine configure node port", e);
    }
  }
Exemplo n.º 3
0
  protected void sendNotifyRequest() {
    ClusterRequest clusterRequest = ClusterRequest.createMulticastRequest(_localClusterNode, true);

    try {
      _controlJChannel.send(null, clusterRequest);
    } catch (Exception e) {
      _log.error("Unable to send notify message", e);
    }
  }
  private FutureClusterResponses doAction() throws ManageActionException, SystemException {

    MethodHandler manageActionMethodHandler =
        PortalManagerUtil.createManageActionMethodHandler(_manageAction);

    ClusterRequest clusterRequest = null;

    if (_clusterGroup.isWholeCluster()) {
      clusterRequest = ClusterRequest.createMulticastRequest(manageActionMethodHandler);
    } else {
      verifyClusterGroup();

      clusterRequest =
          ClusterRequest.createUnicastRequest(
              manageActionMethodHandler, _clusterGroup.getClusterNodeIdsArray());
    }

    return ClusterExecutorUtil.execute(clusterRequest);
  }
Exemplo n.º 5
0
  protected String importTheme(LayoutSet layoutSet, InputStream themeZip) throws Exception {

    ThemeLoader themeLoader = ThemeLoaderFactory.getDefaultThemeLoader();

    if (themeLoader == null) {
      _log.error("No theme loaders are deployed");

      return null;
    }

    ZipReader zipReader = ZipReaderFactoryUtil.getZipReader(themeZip);

    String lookAndFeelXML = zipReader.getEntryAsString("liferay-look-and-feel.xml");

    String themeId = String.valueOf(layoutSet.getGroupId());

    if (layoutSet.isPrivateLayout()) {
      themeId += "-private";
    } else {
      themeId += "-public";
    }

    if (PropsValues.THEME_LOADER_NEW_THEME_ID_ON_IMPORT) {
      Date now = new Date();

      themeId += "-" + Time.getShortTimestamp(now);
    }

    String themeName = themeId;

    lookAndFeelXML =
        StringUtil.replace(
            lookAndFeelXML,
            new String[] {"[$GROUP_ID$]", "[$THEME_ID$]", "[$THEME_NAME$]"},
            new String[] {String.valueOf(layoutSet.getGroupId()), themeId, themeName});

    FileUtil.deltree(themeLoader.getFileStorage() + StringPool.SLASH + themeId);

    List<String> zipEntries = zipReader.getEntries();

    for (String zipEntry : zipEntries) {
      String key = zipEntry;

      if (key.equals("liferay-look-and-feel.xml")) {
        FileUtil.write(
            themeLoader.getFileStorage() + StringPool.SLASH + themeId + StringPool.SLASH + key,
            lookAndFeelXML.getBytes());
      } else {
        InputStream is = zipReader.getEntryAsInputStream(zipEntry);

        FileUtil.write(
            themeLoader.getFileStorage() + StringPool.SLASH + themeId + StringPool.SLASH + key, is);
      }
    }

    themeLoader.loadThemes();

    ClusterRequest clusterRequest =
        ClusterRequest.createMulticastRequest(_loadThemesMethodHandler, true);

    clusterRequest.setFireAndForget(true);

    ClusterExecutorUtil.execute(clusterRequest);

    themeId += PortletConstants.WAR_SEPARATOR + themeLoader.getServletContextName();

    return PortalUtil.getJsSafePortletId(themeId);
  }
    public void run() {
      _countDownLatch.countDown();

      String logPrefix = StringPool.BLANK;

      if (_log.isInfoEnabled()) {
        Thread currentThread = Thread.currentThread();

        if (_master) {
          logPrefix =
              "Monitor thread name "
                  + currentThread.getName()
                  + " with thread ID "
                  + currentThread.getId();
        } else {
          logPrefix =
              "Thread name " + currentThread.getName() + " with thread ID " + currentThread.getId();
        }
      }

      if (!_master && _log.isInfoEnabled()) {
        _log.info(logPrefix + " synchronized on latch. Waiting for others.");
      }

      try {
        if (_master) {
          _countDownLatch.await();
        } else {
          boolean result =
              _countDownLatch.await(
                  PropsValues.LUCENE_CLUSTER_INDEX_LOADING_SYNC_TIMEOUT, TimeUnit.MILLISECONDS);

          if (!result) {
            _log.error(
                logPrefix + " timed out. You may need to " + "re-trigger a reindex process.");
          }
        }
      } catch (InterruptedException ie) {
        if (_master) {
          _log.error(
              logPrefix + " was interrupted. Skip cluster index " + "loading notification.", ie);

          return;
        } else {
          _log.error(
              logPrefix + " was interrupted. You may need to " + "re-trigger a reindex process.",
              ie);
        }
      }

      if (_master) {
        Address localClusterNodeAddress = ClusterExecutorUtil.getLocalClusterNodeAddress();

        ClusterRequest clusterRequest =
            ClusterRequest.createMulticastRequest(
                new MethodHandler(
                    _loadIndexesFromClusterMethodKey, _companyIds, localClusterNodeAddress),
                true);

        try {
          ClusterExecutorUtil.execute(clusterRequest);
        } catch (SystemException se) {
          _log.error("Unable to notify peers to start index loading", se);
        }

        if (_log.isInfoEnabled()) {
          _log.info(logPrefix + " unlocked latch. Notified peers to " + "start index loading.");
        }
      }
    }