Package org.apache.hdt.core.internal.model

Examples of org.apache.hdt.core.internal.model.HDFSServer


      URI locationURI = r.getLocationURI();
      if (locationURI != null && HDFSURI.SCHEME.equals(locationURI.getScheme())) {
        try {
          if (r instanceof IProject) {
            final HDFSManager hdfsManager = HDFSManager.INSTANCE;
            HDFSServer server = hdfsManager.getServer(locationURI.toString());
            if (server != null) {
              String serverUrl = server.getUri();
              String userId = server.getUserId();
              if (userId == null) {
                try {
                  userId = hdfsManager.getClient(serverUrl,server.getVersion()).getDefaultUserAndGroupIds().get(0);
                } catch (Throwable e) {
                  userId = null;
                }
              }
              if (userId == null)
                userId = "";
              else
                userId = userId + "@";
              if (serverUrl != null) {
                try {
                  URI uri = new URI(serverUrl);
                  serverUrl = serverUrl.substring(uri.getScheme().length() + 3);
                } catch (Throwable e) {
                }
              }
              if (serverUrl.endsWith("/"))
                serverUrl = serverUrl.substring(0, serverUrl.length() - 1);
              decoration.addSuffix(" " + userId + serverUrl);
              if (server.getStatusCode() == ServerStatus.DISCONNECTED_VALUE)
                decoration.addOverlay(org.apache.hdt.ui.Activator.IMAGE_OFFLINE_OVR);
              else
                decoration.addOverlay(org.apache.hdt.ui.Activator.IMAGE_ONLINE_OVR);
            } else
              decoration.addSuffix(" [Unknown server]");
View Full Code Here


  public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException {
    if (serverFileInfo == null) {
      serverResourceInfo = null;
      this.effectivePermissions = null;
      FileInfo fi = new FileInfo(getName());
      HDFSServer server = getServer();
      if (server != null) {
        try {
          if (".project".equals(getName())) {
            fi.setExists(getLocalFile().exists());
            fi.setLength(getLocalFile().length());
          } else {
            ResourceInformation fileInformation = getClient().getResourceInformation(uri.getURI(), server.getUserId());
            if (fileInformation != null) {
              serverResourceInfo = fileInformation;
              fi.setDirectory(fileInformation.isFolder());
              fi.setExists(true);
              fi.setLastModified(fileInformation.getLastModifiedTime());
              fi.setLength(fileInformation.getSize());
              fi.setName(fileInformation.getName());
              String userId = server.getUserId();
              List<String> groupIds = server.getGroupIds();
              if (userId == null) {
                userId = getDefaultUserId();
                groupIds = getDefaultGroupIds();
              }
              fileInformation.updateEffectivePermissions(userId, groupIds);
View Full Code Here

      } else {
        ResourceInformation ri = new ResourceInformation();
        ri.setFolder(info.isDirectory());
        if ((options & EFS.SET_LAST_MODIFIED) != 0)
          ri.setLastModifiedTime(info.getLastModified());
        HDFSServer server = getServer();
        getClient().setResourceInformation(uri.getURI(), ri, server == null ? null : server.getUserId());
      }
    } catch (IOException e) {
      throw new CoreException(new Status(IStatus.ERROR, Activator.BUNDLE_ID, e.getMessage(), e));
    } catch (InterruptedException e) {
      throw new CoreException(new Status(IStatus.ERROR, Activator.BUNDLE_ID, e.getMessage(), e));
View Full Code Here

      logger.debug("[" + uri + "]: openRemoteInputStream()");
    if (".project".equals(getName())) {
      return null;
    } else {
      try {
        HDFSServer server = getServer();
        return getClient().openInputStream(uri.getURI(), server == null ? null : server.getUserId());
      } catch (IOException e) {
        throw new CoreException(new Status(IStatus.ERROR, Activator.BUNDLE_ID, e.getMessage(), e));
      } catch (InterruptedException e) {
        throw new CoreException(new Status(IStatus.ERROR, Activator.BUNDLE_ID, e.getMessage(), e));
      }
View Full Code Here

   */
  public File getLocalFile() throws CoreException {
    if (localFile == null) {
      final HDFSManager hdfsManager = HDFSManager.INSTANCE;
      final String uriString = uri.getURI().toString();
      HDFSServer server = hdfsManager.getServer(uriString);
      if (server != null) {
        File workspaceFolder = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile();
        try {
          URI relativeURI = URIUtil.makeRelative(uri.getURI(), new URI(server.getUri()));
          String relativePath = hdfsManager.getProjectName(server) + "/" + relativeURI.toString();
          localFile = new File(workspaceFolder, relativePath);
        } catch (URISyntaxException e) {
          throw new CoreException(new Status(IStatus.ERROR, Activator.BUNDLE_ID, e.getMessage(), e));
        }
View Full Code Here

  public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException {
    if (logger.isDebugEnabled())
      logger.debug("[" + uri + "]: mkdir()");
    try {
      clearServerFileInfo();
      HDFSServer server = getServer();
      if (getClient().mkdirs(uri.getURI(), server == null ? null : server.getUserId())) {
        return this;
      } else {
        return null;
      }
    } catch (IOException e) {
View Full Code Here

  public OutputStream openRemoteOutputStream(int options, IProgressMonitor monitor) throws CoreException {
    if (logger.isDebugEnabled())
      logger.debug("[" + uri + "]: openRemoteOutputStream()");
    try {
      HDFSServer server = getServer();
      clearServerFileInfo();
      if (fetchInfo().exists())
        return getClient().openOutputStream(uri.getURI(), server == null ? null : server.getUserId());
      else
        return getClient().createOutputStream(uri.getURI(), server == null ? null : server.getUserId());
    } catch (IOException e) {
      throw new CoreException(new Status(IStatus.ERROR, Activator.BUNDLE_ID, e.getMessage(), e));
    } catch (InterruptedException e) {
      throw new CoreException(new Status(IStatus.ERROR, Activator.BUNDLE_ID, e.getMessage(), e));
    }
View Full Code Here

        final File plf = lf.getParentFile();
        lf.delete();
        UploadFileJob.deleteFoldersIfEmpty(plf);
      }
      if (isRemoteFile()) {
        final HDFSServer server = getServer();
        if (server != null) {
          if (server.getUri().equals(uri.getURI().toString())) {
            // Server location is the same as the project - so we
            // just
            // disconnect instead of actually deleting the root
            // folder
            // on HDFS.
          } else {
            clearServerFileInfo();
            getClient().delete(uri.getURI(), server == null ? null : server.getUserId());
          }
        } else {
          // Not associated with any server, we just disconnect.
        }
      }
View Full Code Here

  public static HDFSManager INSTANCE = new HDFSManager();
  private static final Logger logger = Logger.getLogger(HDFSManager.class);

  public static void disconnectProject(IProject project) {
    HDFSServer server = HDFSManager.INSTANCE.getServer(project.getLocationURI().toString());
    if (server != null && server.getStatusCode() != ServerStatus.DISCONNECTED_VALUE)
      server.setStatusCode(ServerStatus.DISCONNECTED_VALUE);
    try {
      project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
    } catch (CoreException e) {
      logger.warn(e.getMessage(), e);
    }
View Full Code Here

      logger.warn(e.getMessage(), e);
    }
  }

  public static void reconnectProject(IProject project) {
    HDFSServer server = HDFSManager.INSTANCE.getServer(project.getLocationURI().toString());
    if (server != null && server.getStatusCode() == ServerStatus.DISCONNECTED_VALUE)
      server.setStatusCode(0);
    try {
      project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
    } catch (CoreException e) {
      logger.warn(e.getMessage(), e);
    }
View Full Code Here

TOP

Related Classes of org.apache.hdt.core.internal.model.HDFSServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.