Ask Your Question
0

directories creation random problem

asked 2014-06-18 06:27:33 -0500

anonymous user

Anonymous

updated 2014-06-20 16:33:54 -0500

smaffulli gravatar image

Im doing application that upload folder and file recursively to openstack swift but sometimes some folder the openstack say that is created correctly but its wrong if i find with JSON i get at element like

{Subdir:"<folder_name_with_that_problem>"}

The directories that created correcly i see 2 elements,subdir element and normal element with content type application/directory, date.... etc

If I try to re upload the folder that is wrong, the openstack create correctly the folder. I think is a problem with threads, i put my MKDIR method sync but the problem persist, it's possible openstack need some time to sync the directory creation?

Any idea whats wrong? Sorry for my bad english

edit retag flag offensive close merge delete

Comments

I would suggest you to edit your question and add links to the code you're using and check the logs for errors.

smaffulli gravatar imagesmaffulli ( 2014-06-20 16:34:48 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-06-23 04:10:29 -0500

segator gravatar image

The code is large, i copy the "MKDIR" Method

@Override
public synchronized boolean mkdir() {
    try {
        String mkdir = realHomeDir + virtualFullPath;
        System.out.println("Client:MKDIR " + mkdir);
        HttpURLConnection connection = conexionURL("PUT", mkdir);
        connection.setRequestProperty("Content-Length", "0");
        connection.setRequestProperty("Content-Type", "application/directory");
        connection.connect();
        boolean retorno = connection.getResponseCode() == 201;
        System.out.println("Server:MKDIR " + connection.getResponseCode());
        connection.disconnect();
        return retorno;
    } catch (Exception ex) {
        ex.printStackTrace();
        return false;
    }
}
private HttpURLConnection conexionURL(String metodo, String path) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnsupportedEncodingException, MalformedURLException, IOException {
    path = FileUtils.deleteRootSlash(path);
    HttpURLConnection connection = (HttpURLConnection) new URL(authClient.getEndURL().toString().concat("/default/").concat(URLParamEncoder.URLencoding(path, "UTF-8").replace("%2F", "/").replace("&", "%26"))).openConnection();
    System.out.println(metodo + ":" + connection.getURL().toString());
    TrustModifier.relaxHostChecking(connection);
    connection.setDoOutput(true);
    connection.setInstanceFollowRedirects(false);
    connection.setRequestMethod(metodo);
    connection.setRequestProperty("X-Auth-Token", authClient.getTokenAuth());
    connection.setRequestProperty("Connection", "Keep-Alive");
    connection.setRequestProperty("Cache-Control", "no-cache");
    connection.setUseCaches(false);
    return connection;
}

The URL Creation method work perfect

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

Stats

Asked: 2014-06-18 06:27:33 -0500

Seen: 100 times

Last updated: Jun 23 '14