Skip to content

Commit 225b07e

Browse files
committed
Format whole repository
1 parent c4f9bfb commit 225b07e

File tree

234 files changed

+31629
-30309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+31629
-30309
lines changed

example/cacheCluster/cacheCluster.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ namespace CDNSimulator {
1515

1616
bool CacheCluster::get(request_t *req) {
1717
// find the server idx
18-
uint64_t idx =
19-
ch_ring_get_server_from_uint64(req->obj_id, this->_ring);
18+
uint64_t idx = ch_ring_get_server_from_uint64(req->obj_id, this->_ring);
2019

2120
// find the server
2221
CacheServer &server = this->_cache_servers_vec.at(idx);

example/cacheCluster/consistentHash.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,9 @@ int ch_ring_get_server(const char *const key, const ring_t *const ring) {
136136
return (ring->vnodes + ch_ring_get_vnode_idx(key, ring))->server_id;
137137
}
138138

139-
int ch_ring_get_server_from_uint64(uint64_t obj_id,
140-
const ring_t *const ring) {
141-
char key[8];
142-
memcpy(key, (char *) &obj_id, 8);
139+
int ch_ring_get_server_from_uint64(uint64_t obj_id, const ring_t *const ring) {
140+
char key[8];
141+
memcpy(key, (char *)&obj_id, 8);
143142
key[7] = 0;
144143
return (ring->vnodes + ch_ring_get_vnode_idx(key, ring))->server_id;
145144
}

example/cacheCluster/include/cache.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
#ifndef CDNSIMULATOR_CACHE_HPP
1111
#define CDNSIMULATOR_CACHE_HPP
1212

13+
#include <inttypes.h>
14+
1315
#include <algorithm>
1416
#include <iostream>
15-
#include <inttypes.h>
1617

1718
#include "libCacheSim/cache.h"
1819
#include "libCacheSim/evictionAlgo.h"

example/cacheCluster/include/cacheCluster.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ namespace CDNSimulator {
2424

2525
class CacheCluster {
2626
private:
27-
2827
// the consistent hash ring
2928
ring_t *_ring = nullptr;
3029

example/cacheCluster/include/consistentHash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
extern "C" {
1010
#endif
1111

12+
#include <inttypes.h>
1213
#include <math.h>
1314
#include <stdio.h>
1415
#include <stdlib.h>
1516
#include <string.h>
16-
#include <inttypes.h>
1717

1818
#define N_VNODE_PER_SERVER 160
1919

example/cacheCluster/include/md5.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
2828
This code implements the MD5 Algorithm defined in RFC 1321, whose
2929
text is available at
30-
http://www.ietf.org/rfc/rfc1321.txt
30+
http://www.ietf.org/rfc/rfc1321.txt
3131
The code is derived from the text of the RFC, including the test suite
3232
(section A.5) but excluding the rest of Appendix A. It does not include
3333
any code or documentation that is identified in the RFC as being
@@ -38,17 +38,17 @@
3838
that follows (in reverse chronological order):
3939
4040
2002-04-13 lpd Removed support for non-ANSI compilers; removed
41-
references to Ghostscript; clarified derivation from RFC 1321;
42-
now handles byte order either statically or dynamically.
41+
references to Ghostscript; clarified derivation from RFC 1321;
42+
now handles byte order either statically or dynamically.
4343
1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
4444
1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
45-
added conditionalization for C++ compilation from Martin
46-
Purschke <purschke@bnl.gov>.
45+
added conditionalization for C++ compilation from Martin
46+
Purschke <purschke@bnl.gov>.
4747
1999-05-03 lpd Original version.
4848
*/
4949

5050
#ifndef md5_INCLUDED
51-
# define md5_INCLUDED
51+
#define md5_INCLUDED
5252

5353
/*
5454
* This package supports both compile-time and run-time determination of CPU
@@ -61,18 +61,17 @@
6161
*/
6262

6363
typedef unsigned char md5_byte_t; /* 8-bit byte */
64-
typedef unsigned int md5_word_t; /* 32-bit word */
64+
typedef unsigned int md5_word_t; /* 32-bit word */
6565

6666
/* Define the state of the MD5 Algorithm. */
6767
typedef struct md5_state_s {
68-
md5_word_t count[2]; /* message length in bits, lsw first */
69-
md5_word_t abcd[4]; /* digest buffer */
70-
md5_byte_t buf[64]; /* accumulate block */
68+
md5_word_t count[2]; /* message length in bits, lsw first */
69+
md5_word_t abcd[4]; /* digest buffer */
70+
md5_byte_t buf[64]; /* accumulate block */
7171
} md5_state_t;
7272

7373
#ifdef __cplusplus
74-
extern "C"
75-
{
74+
extern "C" {
7675
#endif
7776

7877
/* Initialize the algorithm. */
@@ -95,7 +94,7 @@ _declspec(dllexport)
9594
void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
9695

9796
#ifdef __cplusplus
98-
} /* end extern "C" */
97+
} /* end extern "C" */
9998
#endif
10099

101100
#endif /* md5_INCLUDED */
Lines changed: 67 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,56 @@
1-
/*
2-
* Copyright (c) 2017, Emory University, All rights reserved.
3-
* Juncheng Yang <jason.yang.china@outlook.com>
4-
*
5-
* Modify for libCacheSim based on original version
6-
* also add const modifier for compiler optimizations
7-
*
8-
*/
9-
10-
11-
1+
/*
2+
* Copyright (c) 2017, Emory University, All rights reserved.
3+
* Juncheng Yang <jason.yang.china@outlook.com>
4+
*
5+
* Modify for libCacheSim based on original version
6+
* also add const modifier for compiler optimizations
7+
*
8+
*/
129

1310
/*
14-
* Copyright (c) 2007, Last.fm, All rights reserved.
15-
* Richard Jones <rj@last.fm>
16-
* Christian Muehlhaeuser <muesli@gmail.com>
17-
*
18-
* Redistribution and use in source and binary forms, with or without
19-
* modification, are permitted provided that the following conditions are met:
20-
* * Redistributions of source code must retain the above copyright
21-
* notice, this list of conditions and the following disclaimer.
22-
* * Redistributions in binary form must reproduce the above copyright
23-
* notice, this list of conditions and the following disclaimer in the
24-
* documentation and/or other materials provided with the distribution.
25-
* * Neither the name of the Last.fm Limited nor the
26-
* names of its contributors may be used to endorse or promote products
27-
* derived from this software without specific prior written permission.
28-
*
29-
* THIS SOFTWARE IS PROVIDED BY Last.fm ``AS IS'' AND ANY
30-
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32-
* DISCLAIMED. IN NO EVENT SHALL Last.fm BE LIABLE FOR ANY
33-
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36-
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39-
*/
11+
* Copyright (c) 2007, Last.fm, All rights reserved.
12+
* Richard Jones <rj@last.fm>
13+
* Christian Muehlhaeuser <muesli@gmail.com>
14+
*
15+
* Redistribution and use in source and binary forms, with or without
16+
* modification, are permitted provided that the following conditions are met:
17+
* * Redistributions of source code must retain the above copyright
18+
* notice, this list of conditions and the following disclaimer.
19+
* * Redistributions in binary form must reproduce the above copyright
20+
* notice, this list of conditions and the following disclaimer in the
21+
* documentation and/or other materials provided with the distribution.
22+
* * Neither the name of the Last.fm Limited nor the
23+
* names of its contributors may be used to endorse or promote products
24+
* derived from this software without specific prior written permission.
25+
*
26+
* THIS SOFTWARE IS PROVIDED BY Last.fm ``AS IS'' AND ANY
27+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29+
* DISCLAIMED. IN NO EVENT SHALL Last.fm BE LIABLE FOR ANY
30+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36+
*/
4037

4138
#ifndef KETAMA_LIBKETAMA_KETAMA_H__
4239
#define KETAMA_LIBKETAMA_KETAMA_H__
4340

44-
#include <sys/sem.h> /* semaphore functions and structs. */
41+
#include <sys/sem.h> /* semaphore functions and structs. */
4542

46-
#define MC_SHMSIZE 524288 // 512KB should be ample.
43+
#define MC_SHMSIZE 524288 // 512KB should be ample.
4744

4845
#ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
4946
extern "C" {
5047
#endif
5148

5249
#ifndef __APPLE__
53-
union semun
54-
{
55-
int val; /* used for SETVAL only */
56-
struct semid_ds *buf; /* for IPC_STAT and IPC_SET */
57-
ushort *array; /* used for GETALL and SETALL */
50+
union semun {
51+
int val; /* used for SETVAL only */
52+
struct semid_ds *buf; /* for IPC_STAT and IPC_SET */
53+
ushort *array; /* used for GETALL and SETALL */
5854
};
5955
#endif
6056

@@ -67,64 +63,63 @@ typedef struct {
6763

6864
typedef struct {
6965
char addr[22];
70-
unsigned long memory; // in CDNSimulator, this is used as weight
66+
unsigned long memory; // in CDNSimulator, this is used as weight
7167
} serverinfo;
7268

7369
typedef struct {
7470
int numpoints;
7571
void *modtime;
76-
void *array; //array of mcs structs
72+
void *array; // array of mcs structs
7773
} continuum;
7874

7975
typedef continuum *ketama_continuum;
8076

8177
/** build a consistent hashing ring
82-
* given the number of servers and the weight of each server.
83-
* if weight is NULL, then each server has equal weight.
84-
* key_identifier is just a number for identifying shared memory */
78+
* given the number of servers and the weight of each server.
79+
* if weight is NULL, then each server has equal weight.
80+
* key_identifier is just a number for identifying shared memory */
8581
int ketama_build_hashring(ketama_continuum *const contptr,
8682
const unsigned int num_servers,
8783
const unsigned long *const weight,
8884
const int key_identifier);
8985

90-
int ketama_get_server_index(
91-
const ketama_continuum cont,
92-
const char *const key);
86+
int ketama_get_server_index(const ketama_continuum cont, const char *const key);
9387

94-
void ketama_get_server_indexes(
95-
const ketama_continuum cont,
96-
const char *const key,
97-
unsigned int n, int *indexes);
88+
void ketama_get_server_indexes(const ketama_continuum cont,
89+
const char *const key, unsigned int n,
90+
int *indexes);
9891

9992
/** \brief Get a continuum struct that contains a reference to the server list.
100-
* \param contptr The value of this pointer will contain the retrieved continuum.
101-
* \param filename The server-definition file which defines our continuum.
102-
* \return 0 on failure, 1 on success. */
93+
* \param contptr The value of this pointer will contain the retrieved
94+
* continuum.
95+
* \param filename The server-definition file which defines our continuum.
96+
* \return 0 on failure, 1 on success. */
10397
int ketama_roll(ketama_continuum *contptr, char *filename);
10498

10599
/** \brief Frees any allocated memory.
106-
* \param contptr The continuum that you want to be destroy. */
100+
* \param contptr The continuum that you want to be destroy. */
107101
void ketama_smoke(ketama_continuum contptr);
108102

109103
/** \brief Maps a key onto a server in the continuum.
110-
* \param key The key that you want to map to a specific server.
111-
* \param cont Pointer to the continuum in which we will search.
112-
* \return The mcs struct that the given key maps to. */
104+
* \param key The key that you want to map to a specific server.
105+
* \param cont Pointer to the continuum in which we will search.
106+
* \return The mcs struct that the given key maps to. */
113107
mcs *ketama_get_server(char *key, ketama_continuum cont);
114108

115109
/** \brief Print the server list of a continuum to stdout.
116-
* \param c The continuum to print. */
110+
* \param c The continuum to print. */
117111
void ketama_print_continuum(ketama_continuum c);
118112

119113
/** \brief Compare two server entries in the circle.
120-
* \param a The first entry.
121-
* \param b The second entry.
122-
* \return -1 if b greater a, +1 if a greater b or 0 if both are equal. */
114+
* \param a The first entry.
115+
* \param b The second entry.
116+
* \return -1 if b greater a, +1 if a greater b or 0 if both are equal. */
123117
int ketama_compare(mcs *a, mcs *b);
124118

125-
/** \brief Hashing function, converting a string to an unsigned int by using MD5.
126-
* \param inString The string that you want to hash.
127-
* \return The resulting hash. */
119+
/** \brief Hashing function, converting a string to an unsigned int by using
120+
* MD5.
121+
* \param inString The string that you want to hash.
122+
* \return The resulting hash. */
128123
unsigned int ketama_hashi(const char *const inString);
129124

130125
/** \brief Hashing function to 16 bytes char array using MD5.
@@ -133,12 +128,11 @@ unsigned int ketama_hashi(const char *const inString);
133128
void ketama_md5_digest(const char *const inString, unsigned char md5pword[16]);
134129

135130
/** \brief Error method for error checking.
136-
* \return The latest error that occurred. */
131+
* \return The latest error that occurred. */
137132
char *ketama_error();
138133

139134
#ifdef __cplusplus /* If this is a C++ compiler, end C linkage */
140135
}
141136
#endif
142137

143-
#endif // KETAMA_LIBKETAMA_KETAMA_H__
144-
138+
#endif // KETAMA_LIBKETAMA_KETAMA_H__

0 commit comments

Comments
 (0)